Skip to main content

Module keyframes

Module keyframes 

Source
Expand description

Keyframes: CSS @keyframes for a node’s animatable slots. A node with NodeSpec::keyframes cycles those slots through the stops over its transition’s duration, in the transition’s repeat direction, held back by its delay_ms — CSS’s animation-* family on a kui node.

The rules are CSS’s (and the Web Animations API’s) where they had one: a stop’s at is optional and missing ones spread evenly between their neighbours (the last defaults to 1, the first to 0 — a lone stop is the far end and animates from the node’s own value); a slot a stop leaves out is simply not part of that stop; and a slot whose stops don’t reach 0 or 1 gets the node’s own declared value there, so a single { at: 0.5, bg } stop is a pulse to that color and back.

Stops arrive as plain data from the bindings (parse), and the runtime flattens them per slot into the tracks [crate::anim::AnimStore::sample] walks.

Structs§

Keyframe
One stop. Every field is optional: at resolves by position, and a slot a stop doesn’t name is left to its neighbours. Derefs to its Slots, so stop.bg reads the slot.

Functions§

offsets
Every stop’s position: declared ats kept, the rest spread evenly between the nearest declared neighbours (0 and 1 at the ends).
parse
Stops from plain data: a list of maps with any of at, width, height, bg, radius, opacity, in the forms the props themselves take (sizings as a number, "grow", "50%", {grow} / {percent}; colors as 0xRRGGBBAA or "#hex"). Every binding funnels its keyframes through here, so the shape is the same in JSX, Lua and C.
parse_with
parse with a token lookup: a $name in a stop’s width, height, bg or radius resolves through refs, and one that misses leaves that slot unnamed and is remembered on the refs for the binding to raise (backlog AR14). Without refs a $name is the error it always was, since there is nothing to resolve it against.