Skip to main content

PageTransition

Enum PageTransition 

Source
pub enum PageTransition {
    None,
    M3SharedAxisX,
    M3FadeThrough,
    IosPush,
    SlideUp,
    Glyph,
    ReducedCrossfade,
    Custom(fn(f64, bool, Size) -> (Layer, Layer)),
}
Expand description

The visual shape of a page transition. The navigator maps the active transition’s progress onto per-page geometry through resolve_layers.

#[allow(unpredictable_function_pointer_comparisons)]: the derived PartialEq/Eq compare a PageTransition::Custom payload by function pointer address, which the compiler flags because that address isn’t guaranteed stable across codegen units. Accepted here deliberately — the contract (documented on Custom) is a best-effort “names the same function” identity check, not a memory-safety- or correctness-critical comparison; the alternative (dropping Eq from the enum) breaks every other variant’s equality for a single edge case. The #[allow] sits at the enum level (not scoped to Custom alone) because a field-level attribute on a tuple-variant payload does not suppress a lint raised inside the derive macro’s generated PartialEq/Eq impl — confirmed by attempting exactly that scoping, which left the warning in place; the derive expands against the whole enum, so only an enum- or module-level #[allow] (or a hand-written impl PartialEq dropping the derive entirely) reaches it.

Variants§

§

None

Instant switch — no animation. The default.

§

M3SharedAxisX

Material 3 shared-axis-X: a 30dp slide paired with a threshold cross-fade.

§

M3FadeThrough

Material 3 fade-through: a staged outgoing fade-out then incoming fade-in with the incoming [M3_FADE_THROUGH_SCALE_START]→1.0 scale-up — the verified Flutter FadeThroughTransition staging. See resolve_layers’s M3FadeThrough arm.

§

IosPush

iOS-style push/pop: incoming slides full-width from the edge; outgoing parallaxes by [IOS_PARALLAX_FRACTION] with an optional dim.

§

SlideUp

Bottom-sheet-style slide-up: the entering page translates in from the bottom (full height → 0); pop reverses (slides back down and out). The page below never moves (a modal sheet floats over a static page, unlike PageTransition::IosPush’s parallaxing below-page). Opacity is always 1.0 for both layers — a sheet’s scrim is a page-owned paint concern (the hosting widget paints/fades its own scrim, e.g. reading the transition progress itself or a fixed alpha), not a Layer-level effect this preset drives; see resolve_layers’s SlideUp arm.

§

Glyph

Glyph screen transition: a directional [GLYPH_SLIDE_DP]-px slide paired with a cross-fade. The entering screen slides in over the theme’s slow spatial timing while the leaving screen accelerates out over the faster exit timing (“exits always faster than entrances”); a pop reverses the slide direction. Timing is resolved from the active MotionScheme via resolve_spec/preset_enter_exit — pair it with Timing::ThemeDefault (or TransitionSpec::glyph).

§

ReducedCrossfade

Pure alpha cross-fade with zero geometric motion (no slide, no scale) — the resolve_spec reduce_motion collapse target (the Glyph design system’s hard accessibility rule: a reduced transition is a short linear cross-fade, never a zoom or slide). Selectable directly, but its primary role is the collapse; see resolve_layers’s arm.

§

Custom(fn(f64, bool, Size) -> (Layer, Layer))

A caller-supplied transition: a third-party design system’s escape hatch for authoring its own page transition without a matching built-in preset. The function maps raw progress (unclamped, so a spring overshoot is visible — the same raw value resolve_layers passes every built-in preset for position) plus is_pop and the page Size onto the (entering, leaving) Layer pair, exactly as a built-in preset’s resolve_layers arm does; resolve_layers invokes it verbatim, with no clamping or post-processing beyond what every preset gets.

A plain function pointer (not Box<dyn Fn>) so Custom keeps every derive PageTransition already has (Copy/Eq included) — a Box<dyn Fn> cannot implement either. Function pointers compare by address, so PartialEq/Eq stay meaningful: two Custom specs are equal iff they name the same function.

Timing. Custom has no MotionScheme tokens of its own — pair it with an explicit Timing::Duration/Timing::Spring for a caller-chosen timing, or Timing::ThemeDefault to fall back to the documented M3 default (300ms + Curve::Emphasized — preset_enter_exit’s fallback arm, matching make_driver’s unthemed ThemeDefault fallback).

Reduce-motion — programmatic path only. resolve_spec’s collapse to PageTransition::ReducedCrossfade applies to Custom like every other preset when a transition is staged programmatically (a push/pop/replace carrying a TransitionSpec): the navigator resolves it against the active reduce_motion flag on the transition’s first paint, before the preset is ever consulted, so a Custom fn staged that way is not called.

A user-driven interactive edge-swipe pop is a different path: it is not routed through that collapse at all — the navigator drives the popped page’s own preset directly, raw, with no resolve_spec step — so under reduce_motion the supplied function is still called there. This is not specific to Custom: every built-in preset behaves identically on an interactive pop (a pre-existing accessibility gap, unrelated to Custom and tracked separately — this doc narrows the claim to what the code does, it does not fix the gap).

Trait Implementations§

Source§

impl Clone for PageTransition

Source§

fn clone(&self) -> PageTransition

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PageTransition

Source§

impl Debug for PageTransition

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for PageTransition

Source§

fn default() -> PageTransition

Returns the “default value” for a type. Read more
Source§

impl Eq for PageTransition

Source§

impl PartialEq for PageTransition

Source§

fn eq(&self, other: &PageTransition) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PageTransition

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Brush for T
where T: Clone + PartialEq + Default + Debug,

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more