framer-motion
Version:
A simple and powerful JavaScript animation library
17 lines (14 loc) • 543 B
JavaScript
import { frame, cancelFrame, frameData, time } from 'motion-dom';
const frameloopDriver = (update) => {
const passTimestamp = ({ timestamp }) => update(timestamp);
return {
start: () => frame.update(passTimestamp, true),
stop: () => cancelFrame(passTimestamp),
/**
* If we're processing this frame we can use the
* framelocked timestamp to keep things in sync.
*/
now: () => (frameData.isProcessing ? frameData.timestamp : time.now()),
};
};
export { frameloopDriver };