requestAnimationFrameInterval
is interval excute callback using requestAnimationFrame.
If you use repeatedly requestAnimationFrame
then inconvenient.
// sample
var key = requestAnimationFrame(function loop(){
// Do something
key = requestAnimtionFrame(loop);
});
// stop requestAnimationFrame
cancelAnimationFrame(key);
So, I make requestAnimationFrameInterval
. It is similar setInterval. Very Simple. and You make readable code more.
// sample
var key = requestAnimationFrameInterval(function(timestamp, count){
// Do something
});
// stop requestAnimationFrameInterval
cancelAnimationFrameInterval(key);
bower install requestAnimationFrameInterval
In your web page:
<script src="[path_to_dist]/rafi.js>"></script>
window.requestAnimationFrameInterval(function callback(timestamp, count){
});
timestamp | count |
---|---|
DOMHighResTimeStamp | callcount |