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§
- Background
Transition - Active
Transition<Color>driving an entity’s solidVisuals::fill(CSStransition: background-color). Started by the restyle path (theme / class flips) when the computed background changes; hover / press pseudo-class tints keep their own FSM incrate::hover(which reads the sameTransitionSpecsfor duration + easing). - Border
Color Transition - Active
Transition<Color>drivingVisuals::border.color. - Opacity
Transition - Active
Transition<f32>driving an entity’sOpacity. Spawned when a class flip changes the resolved opacity and the entity carries a matchingTransitionSpec. The driver removes this component when the transition completes. - Text
Color Transition - Active
Transition<Color>drivingTextStyle::color. - Transition
- One-shot transition between two values of a tween-able type.
- Transition
Plugin - Plugin: registers every per-property transition driver in
TickStage::Systems. Add viaApp::add_plugin(TransitionPlugin)once; subsequent additions are no-ops as long as the same instance is reused. - Transition
Spec - Author-declared transition. CSS shorthand
transition: opacity 200ms ease-outlands as one of these per comma-separated entry. The runtime stores all specs for an entity in aTransitionSpecscomponent and consults them when a relevant property changes (e.g. on a class flip). - Transition
Specs - Every
TransitionSpecdeclared for an entity, in source order.
Enums§
- Easing
- Easing curve sampled by
Easing::apply. The curves match common CSS / native-control timings: - Transition
Property - Property identifier for a
TransitionSpec.
Traits§
- Lerp
- Tween-able value. Implementations should return a linear interpolation
between
selfandotherat fractiontin[0, 1]. Implementations are free to assumetis already easing-adjusted byEasing::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
BackgroundTransitioninto the entity’s solidVisuals::fill. Gradient fills are never animated (the component is dropped on sight). A fill some runtime system holds inStyleOverrides(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
BorderColorTransitionintoVisuals::border.color. A border removed mid-flight retires the tween (nothing left to paint). - step_
opacity_ transitions - Sample every active
OpacityTransitionand write the result into the entity’sOpacity. When the transition is done, snap to the final value and despawn the transition component. - step_
text_ color_ transitions - Sample every active
TextColorTransitionintoTextStyle::color.