MotionLightweight
State machines
Named states and the allowed moves between them.
A list of named states (idle, hover, pressed, dragging) and the allowed moves between them. It stops two states from being true at once and gives every transition a place to be designed. Rive builds these into its files.
- Breaks when
- over-engineered for a single hover
- Also called
- XState, Rive state machine, FSM
Prompts
Drag interaction that never glitches
Model a draggable card with XState v5: states idle → hover → pressed → dragging → released, with guards (pressed becomes dragging only after 6 px of movement), timed transitions (released → idle after 200 ms) and actions that set spring targets. Render the state name in a debug badge. Every visual property (scale, shadow, cursor) is derived from the state, never set ad hoc in event handlers.
Scene phases for a 3D intro
A state machine for a Three.js hero: loading → intro → idle ↔ focused (a product is selected) → detail, each state owning its camera target, its allowed input, and its enter/exit tweens. Transitions are the only place a tween is started. Provide a keyboard shortcut per state for testing.
Rive state machine inputs
Design the state machine for a Rive character: inputs isHovered (bool), energy (number 0–100), tap (trigger); states idle, alert, happy, sleepy with blend by energy; document the transition conditions and durations so the Rive file and the web code agree.