Skip to content

CatChen/requestAnimationFrame

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 

This is a requestAnimationFrame implementation in JavaScript.

What is requestAnimationFrame?

If you don't know what requestAnimationFrame is, you can see the latest draft of the spec. It's a browser API for script-based animation. It allows the browser to control the frame rate in order to make the animation smooth while saving computation power so you don't have to worry about that.

How to use it?

var animationHandle;

function startAnimation() {
    drawAnimationFrame();
};

function stopAnimation() {
    window.cancelRequestAnimationFrame(animationHandle);
};

function drawAnimationFrame() {
    /* draw your animation frame here */
    animationHandle = window.requestAnimationFrame(drawAnimationFrame);
};

About

A JavaScript implementation of requestAnimationFrame

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published