Skip to main content

Module animation

Module animation 

Source
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§

AnimationDef
A keyframe set (style.json animations.<name>).
AnimationFrame
One frame: every channel at its value (band None = no shimmer band).
AnimationTiming
Duration and easing of an animation under a theme.
Band
The shimmer band: its colour token and alpha stops across the band.
BandStop
Keyframe
One keyframe (absent channels = the rest value).

Enums§

AnimationEasing
An easing: a cubic bezier [x1, y1, x2, y2] or linear.
InfiniteTag
Iterations
Iterations: a count or infinite.
LinearTag
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.json order.

Functions§

animates_opacity
Whether a keyframe set animates opacity (animatesOpacity).
animation_frame
The frame elapsed_ms after the node entered the tree. Finished finite animations hold their last keyframe; reduced_motion = the rest keyframe, 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 name under theme: the duration token (or duration_token, the node’s animationDuration) × factor.
animation_timing_ms
animation_timing with the node’s animationDuration already 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 name under a RESOLVED timing (what a painter keeps from crate::style::Visual::animation; no theme needed).
keyframes_css
The CSS @keyframes xui-<name> rule (keyframesCss): opacity moves --xui-a-opacity (the node’s opacity multiplies it), the shimmer band --xui-band; needs ANIMATION_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.