Control speed and pause, play a pattern once for a result, drive a loader from a progress value, and choose how a change travels over the dots.
Engine · 2 min read
A loader loops by default. These props change how it moves, and how it moves from one state to the next.
Speed and pause
look.speed scales the loop: 2 is twice as fast, 0.5 half as fast. A preset allows 0.05 to 10. state="paused" holds the current frame.
<DotMatrix pattern="helix" look={{ speed: 2 }} />
<DotMatrix pattern="helix" state={busy ? "running" : "paused"} />Play once for a result
A scene with once plays one time and holds its last frame. Use it for a result, not a wait. check and cross are built in. Their outcome tells screen readers "Done" or "Something went wrong". Press Replay to see them again.
Follow a value
value is an input from 0 to 1, such as a download's progress or a voice level. Patterns with an input bake it in steps. The canvas and WebGL renderers blend the two nearest steps, so the dots move smoothly as value changes. The DOM and SVG renderers show the nearest step.
<DotMatrix pattern="progressRing" lattice="circle" value={loaded / total} />In your own scene, read the input with { "fn": "ref", "name": "input" } and set the scene key input to the number of steps, from 2 to 65. The built-in progress uses 33. More steps cost more bake time.
Change state
When pattern, lattice or color changes, the dots travel from the old state to the new one in 560ms. look.morph sets the order the dots move in:
morph | How the dots move |
|---|---|
wave (default) | A ring spreads out from the middle |
implode | From the edge to the middle |
sweep | From one side to the other |
dissolve | In a random order |
flow | Every dot at the same time, a smooth blend |
fly | Each lit dot flies to a new place |
none | At once, with no motion |
<DotMatrix pattern={done ? "check" : "spinner"} look={{ morph: "fly" }} />A morph needs a running loader on screen. A paused or hidden loader, and a change of size, look.dot, look.glow, look.floor or renderer, swap at once.
Two more props cover the edges of a loader's life:
active={false}morphs every dot dark, for an exit. Keep the loader mounted while it fades.entermorphs in from dark the first time the loader comes on screen.
Loading states shows these props wired to real app state.