npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

request-animation-loop

0.1.0 • Public • Published

request-animation-loop

setInterval is to setTimeout as requestAnimationLoop is to requestAnimationFrame.

npm version Build Status

Install

npm install request-animation-loop --save

Example

Rotate an element for 1 second.

var deg = 0;
var id = requestAnimationLoop(function (deltaTime) {
  deg += deltaTime * 0.1;
  el.style.transform = "rotate(" + deg + "deg)";
});
 
setTimeout(function () {
  cancelAnimationLoop(id);
}, 1000);

API

requestAnimationLoop(callback(deltaTime, id))

Start an animation loop with function callback which recieves a time in milliseconds since last iteration as deltaTime and id which is the id of the loop.

cancelAnimationLoop(id)

Stop animation loop with id id.

install

npm i request-animation-loop

Downloadsweekly downloads

1

version

0.1.0

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability