pub struct ViewTransition { /* private fields */ }Expand description
Animates page changes inside a layout. Use it instead of Outlet::show:
fn layout(ui: &mut egui::Ui, outlet: Outlet) {
ui.heading("My app"); // shared chrome: stays put
ViewTransition::slide().show(ui, outlet);
}When the user prefers reduced motion (the browser’s prefers-reduced-motion on the web, or
ViewTransition::reduced_motion), offsets are dropped and only the fading remains, like the
blog post’s @media (prefers-reduced-motion) suggestion.
Implementations§
Source§impl ViewTransition
impl ViewTransition
Sourcepub fn slide() -> Self
pub fn slide() -> Self
The blog post’s transition: the old page fades out quickly while sliding away, the new one fades in a bit later while sliding in. Mirrored when going back.
Sourcepub fn slide_by(distance: f32) -> Self
pub fn slide_by(distance: f32) -> Self
ViewTransition::slide with a custom distance in points.
Sourcepub fn custom(
effect: impl Fn(&TransitionFrame) -> (Layer, Layer) + 'static,
) -> Self
pub fn custom( effect: impl Fn(&TransitionFrame) -> (Layer, Layer) + 'static, ) -> Self
Your own effect: return how the old and the new page are drawn for a frame.
Sourcepub fn reduced_motion(self, reduced: bool) -> Self
pub fn reduced_motion(self, reduced: bool) -> Self
Overrides the reduced-motion preference (by default: the browser’s setting on the web, off on native).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ViewTransition
impl !Send for ViewTransition
impl !Sync for ViewTransition
impl !UnwindSafe for ViewTransition
impl Freeze for ViewTransition
impl Unpin for ViewTransition
impl UnsafeUnpin for ViewTransition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more