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)
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.
Checkout requestAnimationFrame for Smart Animating By Paul Irish
Browser support using the requestFrame polyfill. npm i --save request-frame
- IE 5.5+
- IE10+
See caniuse for more details.
MIT License
Copyright (c) 2016 Julien Etienne