Skip to main content

Module transition

Module transition 

Source
Expand description

Generic per-property tween primitive.

Transition<T> carries a start value, end value, start instant, duration, and easing. Querying Transition::sample returns the interpolated value at any wall-clock instant; once Transition::done is true the transition can be retired.

The crate ships the primitive plus a Lerp impl for f32 and Color - concrete property bridges (CSS transition: opacity -> Transition<f32> driving Opacity, CSS transition: bg -> Transition<Color> driving [Visuals.fill]) live in the CSS application layer, not here.

Designed for the markup-driven CSS transition: shorthand (Transitions Level 1 spec). Hover/press tints in crate::hover keep their bespoke state machine - their bidirectional snap-on-state- flip semantics don’t fit a one-shot transition.

Structs§

BackgroundTransition
Active Transition<Color> driving an entity’s solid Visuals::fill (CSS transition: background-color). Started by the restyle path (theme / class flips) when the computed background changes; hover / press pseudo-class tints keep their own FSM in crate::hover (which reads the same TransitionSpecs for duration + easing).
BorderColorTransition
Active Transition<Color> driving Visuals::border.color.
OpacityTransition
Active Transition<f32> driving an entity’s Opacity. Spawned when a class flip changes the resolved opacity and the entity carries a matching TransitionSpec. The driver removes this component when the transition completes.
TextColorTransition
Active Transition<Color> driving TextStyle::color.
Transition
One-shot transition between two values of a tween-able type.
TransitionPlugin
Plugin: registers every per-property transition driver in TickStage::Systems. Add via App::add_plugin(TransitionPlugin) once; subsequent additions are no-ops as long as the same instance is reused.
TransitionSpec
Author-declared transition. CSS shorthand transition: opacity 200ms ease-out lands as one of these per comma-separated entry. The runtime stores all specs for an entity in a TransitionSpecs component and consults them when a relevant property changes (e.g. on a class flip).
TransitionSpecs
Every TransitionSpec declared for an entity, in source order.

Enums§

Easing
Easing curve sampled by Easing::apply. The curves match common CSS / native-control timings:
TransitionProperty
Property identifier for a TransitionSpec.

Traits§

Lerp
Tween-able value. Implementations should return a linear interpolation between self and other at fraction t in [0, 1]. Implementations are free to assume t is already easing-adjusted by Easing::apply.

Functions§

retarget
CSS-retarget rule: when a transition re-triggers mid-flight, the new tween starts from the CURRENT interpolated value (the live component value the previous driver tick wrote), never the old endpoint. This helper builds that tween; equal endpoints return None (equal-value writes are no-ops, no zombie transitions).
step_background_transitions
Sample every active BackgroundTransition into the entity’s solid Visuals::fill. Gradient fills are never animated (the component is dropped on sight). A fill some runtime system holds in StyleOverrides (a hover or press tint, a toggle’s state) is that system’s to paint, so the restyle tween is retired rather than left to fight over the colour.
step_border_color_transitions
Sample every active BorderColorTransition into Visuals::border.color. A border removed mid-flight retires the tween (nothing left to paint).
step_opacity_transitions
Sample every active OpacityTransition and write the result into the entity’s Opacity. When the transition is done, snap to the final value and despawn the transition component.
step_text_color_transitions
Sample every active TextColorTransition into TextStyle::color.