'play-safe' requestAnimationFrame (also safe for iOS)
draf is a safe way to play requestAnimationFrame
and cancelAnimationFrame
. Might be used to build animation library, or just to build simple gallery. This script also provides better replacement for setTimeout, clearTimeout, setInterval, and clearInterval. They are requestTimeout, clearRequestTimeout, requestInterval
and clearRequestInterval
To be clear, this script is copy & mixing of:
And say thanks very much to:
Benefits of using requestAnimationFrame
Just use this like in pure requestAnimationFrame & cancelAnimationFrame :
requestAnimationFrame
cancelAnimationFrame
Also providing the drop-in replacement for setTimeout, clearTimeout, setInterval, clearInterval
. This will use the requestAnimationFrame
when possible for better performance. Just use this replacement like their pure way :
requestTimeout
clearRequestTimeout
requestInterval
clearRequestInterval
Public License
Feel free to contact me on twitter if you find issue/ bug in this script
@drizzlecloudy or drizzlecloudy {at} gmail.com