Read the root AGENTS.md first. This file adds motion-specific rules.
Spring and easing animations, transitions, sequencing (sequence, parallel), keyframes, and the shared interval timer pool (timer-pool.ts). Respects the NO_MOTION capability flag.
- Honor
caps.motion. When motion is off, animations jump to their final state instead of stepping. Guard timer subscriptions with it. - Use the shared timer pool (
timerPoolSubscribe) rather than rawsetIntervalso many animations share one timer. - Animation functions return a cancel function. Always return one, even for a no-op or empty input.
- Pure timing math (easing, interpolation) takes elapsed milliseconds and returns a value. Keep it side-effect free so it is trivial to test.
- Mock
caps.motionwithvi.spyOn(caps, 'motion', 'get').mockReturnValue(false)and restore inafterEach. - Test timing functions by calling them with explicit elapsed values. Do not rely on real time.
- Call
timerPoolUnsubscribeAll()in teardown to avoid leaked timers across tests.
bun vitest run packages/motion