Play.js
Agnostic frame-skipping animation library
Performs an abstract transition for a fixed amount of time, regardless of the
frame rate of the page (frame skipping.) Calls an onFrame
callback with a
0-to-1 float ratio (representing the progress of the transition) as often as
the browser can perform.
Play.start({
time: 1,
onFrame: function(r) {
console.log('Animation is at ' + (r * 100).toFixed(2) + '%');
}
});
Play.start({
time: 0.1,
easing: function(r) {
return 0.5 - Math.cos(r * Math.PI) / 2;
},
onFrame: function(r) {
console.log(r);
}
});
var myAnimation = Play.start({time: 5});
Play.stop(myAnimation);
Play.end(myAnimation);
Play.start({time: 1, ratio: 0.5});
Play.start({time: 5, function(r) {
$('.my-element').css({top: r / 2, left: r});
}});
var Play = require('play-js').Play;