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.
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
impl Clone for PageTransition
Source§fn clone(&self) -> PageTransition
fn clone(&self) -> PageTransition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PageTransition
Source§impl Debug for PageTransition
impl Debug for PageTransition
Source§impl Default for PageTransition
impl Default for PageTransition
Source§fn default() -> PageTransition
fn default() -> PageTransition
impl Eq for PageTransition
Source§impl PartialEq for PageTransition
impl PartialEq for PageTransition
impl StructuralPartialEq for PageTransition
Auto Trait Implementations§
impl Freeze for PageTransition
impl RefUnwindSafe for PageTransition
impl Send for PageTransition
impl Sync for PageTransition
impl Unpin for PageTransition
impl UnsafeUnpin for PageTransition
impl UnwindSafe for PageTransition
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
impl<T> Brush for T
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.