draf

'play-safe' requestAnimationFrame (also safe for iOS)

View the Project on GitHub drizzlecloudy/draf

Description

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

Benefits of using requestAnimationFrame

Download

Click this

Usage

Just use this like in pure 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 :

License

Public License

Note

Feel free to contact me on twitter if you find issue/ bug in this script
@drizzlecloudy or drizzlecloudy {at} gmail.com