Tiny FLIP animation utility (translate + optional scale) with Promise-based play and reduced-motion support.
npm install @mkja/flip-motionTiny FLIP animation utility (translate + optional scale) with Promise-based play and reduced-motion support.
Install from npm:
``bash`
npm install @mkja/flip-motion
`js
import flip from '@mkja/flip-motion';
const elements = document.querySelectorAll('li');
const ctrl = flip(elements);
// Mutate DOM (reorder/insert/remove)
// ...
await ctrl.play({ duration: 300, easing: 'ease' }).finished;
`
- flip(elements) → controller with:play(options)
- → { animations: Animation[], finished: Promisemeasure()
- → refresh internal measurementsupdate([elements])
- → rebind or just refresh measurementscancel()
- → cancel in-flight animationsdisconnect()
- → release references
- duration (ms, default 100)easing
- (default ease)delay
- (default 0)stagger
- (ms per index, default 0)fill
- (default auto)direction
- (default normal)composite
- (default add)shouldScale
- (default true)respectReducedMotion
- (default true)transformOrigin
- (default "0 0")epsilon
- (px threshold to skip, default 0.5)
- Dev demo: npm run dev (serves test/index.html with Vite)npm test
- Tests: npm run lint
- Lint: npm run format
- Format:
Uses WAAPI (element.animate). If unavailable, calls are no-ops. Honors prefers-reduced-motion`.
MIT