LoopyJS
A polyfill and wrapper for requestAnimationFrame, providing common functionality for animation and timing loops
Build
Make sure you have grunt-cli installed
$ npm install
$ grunt build
Usage
Loop some code, and cancel the loop after 1000ms
var animation = ;
You can use the this
context
;
You can access other less common information with this
context
;
You can use loopy.request like you would normally use requestAnimationFrame, except the callback time is given as time since the request, instead of currentTime
loopy;
You can use built-in animation helpers.
var options = initial : 100 halflife : 1000 //miliseconds growth: false //true for growth instead of decay; loopy;
var options = amplitude: 100 phase: 0 //radians period: 1000 //miliseconds; loopy;
You should never place code inside an event handler that is listening to the window scroll
event.
This is because the scroll event can be fired a lot more than is needed, slowing down the browser.
Instead, you can use the loopy.scroll(callback);
method
loopy;
Contributing
All help is welcome!
Possible future updates include
- More tests
- Examples
- Wrapper for common animations
- Linear
- Bezier easing
- Animation time config
- Play / Pause / Rewind methods