Expand description
Core transition patterns: the object-safe TransitionPattern trait plus
the four source-verified patterns — FadeThrough, SharedAxis
(X/Y/Scaled), FadeScale, and ContainerTransform (rect-to-rect
morph + fade-through composite) — that
super::switcher::PatternSwitcher stages an outgoing/incoming child pair
under. A design system’s own patterns live in its own crate
(frust_glyph::motion is the shipped example) and implement the same
public trait from there.
§Pure staging math, no widgets
A pattern is pure staging math: given a 0.0..=1.0 transition progress
(p), a reverse flag, and the container Size, it yields per-child
paint parameters (PatternLayer — {alpha, dx, dy, scale}) for the
incoming and exiting children. It never touches a widget, so the
staging numbers are table-testable in isolation (mirroring
nav::transition::resolve_layers’s pure-geometry precedent); the switcher
is the sole consumer that applies a resolved PatternLayer via
push_layer/push_transform and a pod-origin offset.
§Progress: raw for position, clamped for opacity
p is raw — a spring Timing can overshoot past
1.0, and that overshoot is applied to position/scale so a slide visibly
springs past its rest spot. Opacity always uses the [0, 1]-clamped value
(push_layer alpha is never meaningful outside that range) — the same
split nav::transition::resolve_layers uses.
§Source-verified staging numbers
Every constant below is either a Material 3 published value or a
source-verified Flutter animations-package number, cited per constant
per docs/CODE_STANDARDS.md’s named-constant rule.
§Scaffold contract
This file owns its own contents only — the TransitionPattern trait and
the four patterns above all live here and never edit motion/mod.rs’s
module list or re-export block (see that module’s docs).
The trait’s size parameter is a deliberate extension point the
hero-rect-bearing patterns hang off of, kept in the signature now so a
boxed dyn TransitionPattern never needs a shape change.
Structs§
- Container
Transform - Material 3 “container transform” (Flutter
OpenContainersemantics): the incoming content morphs from a capturedsourcerect to atargetrect while opacity fades the source content out and the incoming content in. - Fade
Scale - Material 3 “fade scale” (Flutter
FadeScaleTransition): the incoming child fades in over the first 30% of the timeline while scaling [FADE_SCALE_SCALE_START]→1.0over the full timeline ([FADE_SCALE_SCALE_CURVE]); the exiting child fades only (no scale). Non-directional —reversehas no geometric effect (it selects the fasterFADE_SCALE_REVERSEduration at the switcher’s timing layer instead). The idiomatic pattern for a dialog/menu/FAB appearing over stable content. - Fade
Through - Material 3 “fade through”: the outgoing child fades
1→0over the first 6/20 of the timeline then holds, while the incoming child holds at [FADE_THROUGH_SCALE_START] scale /0opacity for that 6/20 then fades in and scales up to1.0over the remaining 14/20. Non-directional (no slide) —reversehas no effect. The idiomatic pattern for a destination change with no spatial relationship (bottom-nav switch, account switch), and thereduce_motioncollapse target. - Pattern
Layer - Per-child paint parameters for one frame of a pattern transition: a paint
offset (added to the child’s pod origin, so paint and hit-testing move
together), an opacity (composited via
push_layer), and a uniform scale (composited viapush_transformabout the child’s centre).
Enums§
- Container
Fade - How a
ContainerTransformstages opacity while its bounds morph (the fade / fadeThrough variants). - Shared
Axis - Which axis (or the scaled variant) a
SharedAxistransition moves along.
Constants§
- CONTAINER_
TRANSFORM_ DURATION - ContainerTransform default duration — the Material 3 container-transform /
Flutter
OpenContainer300ms morph. - FADE_
SCALE_ FORWARD - Fade-scale default forward duration — Flutter
FadeScaleTransition’s 150ms enter. A source-verified pattern-native constant the switcher’s caller can pass to.timing(...); the switcher’s own default resolves from the theme instead. - FADE_
SCALE_ REVERSE - Fade-scale default reverse duration — Flutter
FadeScaleTransition’s 75ms exit (“exits always faster than entrances”). SeeFADE_SCALE_FORWARD.
Traits§
- Transition
Pattern - Pure staging math for a keyed child switch: maps a
0.0..=1.0transition progress onto per-childPatternLayers for the incoming and exiting children. See the module docs for the raw-vs-clamped progress contract.