Expand description
Round 2 (docs/round-2-contract.md §2, animation): the token-only
animation style key. catalog/style.json animations holds the
keyframe sets; this module turns one into what a painter needs at a
moment — the duration from the theme’s motion tokens, per-segment easing,
the channel values (opacity, translate, rotate, scale, the shimmer band)
— and into CSS @keyframes. Mirrors src/animation.ts;
fixtures/animations.json locks the sampled frames.
A painter keeps the moment the node entered the tree (first paint,
visible turning true, a template item appearing) and asks
animation_frame each frame; channels compose OUTSIDE the node’s own
transform, about the box centre; opacity multiplies.
Structs§
- Animation
Def - A keyframe set (
style.json animations.<name>). - Animation
Frame - One frame: every channel at its value (
bandNone= no shimmer band). - Animation
Timing - Duration and easing of an animation under a theme.
- Band
- The shimmer band: its colour token and alpha stops across the band.
- Band
Stop - Keyframe
- One keyframe (absent channels = the rest value).
Enums§
- Animation
Easing - An easing: a cubic bezier
[x1, y1, x2, y2]or linear. - Infinite
Tag - Iterations
- Iterations: a count or infinite.
- Linear
Tag - The literal
"linear".
Constants§
- ANIMATION_
NAMES - The names (
pulse spin fade-in slide-in-up/down/left/right shimmer). - ANIMATION_
PROPERTIES_ CSS - The custom properties the keyframes animate, registered so they
interpolate (
--xui-a-opacity, the opacity factor;--xui-band, the shimmer band). A CSS renderer adds this ONCE per document. - REST
Statics§
- ANIMATIONS
- The keyframe sets by name, in
style.jsonorder.
Functions§
- animates_
opacity - Whether a keyframe set animates opacity (
animatesOpacity). - animation_
frame - The frame
elapsed_msafter the node entered the tree. Finished finite animations hold their last keyframe;reduced_motion= therestkeyframe, no band. - animation_
running - Whether the animation still moves at
elapsed_ms(a painter stops requesting frames once a finite one finished). - animation_
timing - Duration and easing of
nameundertheme: thedurationtoken (orduration_token, the node’sanimationDuration) ×factor. - animation_
timing_ ms animation_timingwith the node’sanimationDurationalready resolved to ms ($motion.<name>→ its value): it replaces the set’s duration token, the factor is kept.- cubic_
bezier - y of a CSS cubic-bezier at x (bisection on x, 60 steps: deterministic).
- frame_
with_ timing - The frame of
nameunder a RESOLVED timing (what a painter keeps fromcrate::style::Visual::animation; no theme needed). - keyframes_
css - The CSS
@keyframes xui-<name>rule (keyframesCss): opacity moves--xui-a-opacity(the node’sopacitymultiplies it), the shimmer band--xui-band; needsANIMATION_PROPERTIES_CSS. - painted_
opacity - The painted opacity of an animating node: its own (default 1) × the
frame’s, never replaced (a finished fade-in keeps the author’s
opacity).
paintedOpacity.