runFor(fn, ms)
Run a performant function for a period of time
Run requestAnimationFrame
for the specified duration.
Install
npm install --save runfor
or
yarn add runfor
Usage
;
Example
; { // Move right 200px divstyletransform = `translateX(px`;} // Run moveX for 1sec with a progress between 0 and 1.;
Check the examples/
folder to see full examples.
API
Optionally you can stop or start the animation with this functions:
const runner = ; runnerrunnerrunnerstart
.stop()
Stops the animation.
.start()
Starts the animation keeping the previous progress.
.toggle()
Toggle start / stop.
.restart()
Restart animation from the beginning
Development
yarn install
yarn run dev
Test
yarn test