Neanderthal Painting Monet

    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

    2

    Version

    0.1.0

    License

    ISC

    Last publish

    Collaborators

    • olahol