0.0.2 • Published 8 years ago
set-animation-interval v0.0.2
setAnimationInterval()
Repeatedly call a function without setInterval, call a function by approximate frames per second
npm i --save set-animation-interval
= A better performing setInterval with frames per second
also...npm i --save set-animation-frame
= A better performing setTimeout
// Heads up!
// Animation timing functions work in enviroments that either render or
// simulate the rendering of frames. (Unlike nodejs & dev tools)
Usage:
var requestID = setAnimationInterval(<Callback>, <delay>, <useFPS>);
Callback : The function to be executed between each delay.
delay : The delay in milliseconds or frames per second if useFPS is truthy.
useFPS : If true, the delay value is interpreted by FPS. It is false by defualt.
- setAnimationInterval returns the requestID for cancellation via cancelRequestAnimationFrame() (polyfill).
- setAnimationInterval passes the given function the DOMHighResTimeStamp as a parameter.
Why avoid setInterval?
Checkout requestAnimationFrame for Smart Animating By Paul Irish
Browser support using the requestFrame polyfill. npm i --save request-frame
- IE 5.5+
Browser Support Without a polyfill or vendor prefix usage.
- IE10+
See caniuse for more details.
MIT License
Copyright (c) 2016 Julien Etienne