JavaScript API
Every animating component exposes a Web-Animations-style playback surface: play(), pause(), finish(), cancel(), a playState getter, and a finished promise — plus package-level helpers to control everything at once.
Controlling playback
Triggering a one-shot and awaiting it
Controlling everything at once
The package exports registry-backed helpers that operate on every live instance, or only those inside a container you pass. Input-driven components (motion-hover, motion-press, motion-magnetic, motion-tilt) have no timeline; pauseAll() disables them and resumeAll() re-enables only the ones it disabled.
Instance members
| Member | Type | Default | Description |
|---|---|---|---|
| | () => Promise<void> | — | Start if idle or finished, resume if paused, no-op if running |
| | () => void | — | Freeze in place; resumable with play() |
| | () => void | — | Jump to the end state immediately |
| | () => void | — | Hard terminate and reset to the initial state |
| | PlaybackState | 'idle' | 'idle' | 'running' | 'paused' | 'finished' |
| | Promise<void> | — | Fresh per run; resolves on finish or cancel, never rejects |
Package exports
| Export | Type | Default | Description |
|---|---|---|---|
| | (root?: Node) => void | document | Pause running instances inside root; disable input-reactive components |
| | (root?: Node) => void | document | Resume paused instances; re-enable only what pauseAll disabled |
| | (root?: Node) => void | document | Cancel every instance inside root |
| | interface | — | TypeScript type for controllable element refs |
| | type | — | The four-state playback union |
Scroll-driven components
For motion-parallax, motion-scene, motion-progress, and motion-blur the verbs adapt: pause() unbinds the scroll listener and freezes the effect at its current progress, play() rebinds, finish() applies the end-of-scroll state, and cancel() unbinds and resets styles. While bound, playState is 'running'.
Accessibility
The API always respects prefers-reduced-motion: a programmatic play() applies the final state instantly, still resolves finished, and still fires motion-start and motion-finish — so calling code never needs a reduced-motion branch.