Skip to content

newtonjs/frame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

newtonjs/frame

Animation frame wrapper.

Version: 0.1.0
Build status: Build Status

Usage

var frame = require('newtonjs-frame');

var animate, id;
(animate = function (time) {
  // Render the current frame...

  // ...then request the next one
  id = frame.request(animate);
})({});

if (/* Some condition */) {
  frame.cancel(id);
}

The time argument passed to the callback is much more useful than the one given directly by requestAnimationFrame.

var frame = require('newtonjs-frame');

frame.request(function (time) {
  console.log(time.now);       // Timestamp of current
  console.log(time.last);      // Timestamp of last
  console.log(time.start);     // Timestamp of start
  console.log(time.delta);     // Milliseconds since last
  console.log(time.progress);  // Milliseconds since start
});

If you merely require a polyfill for requestAnimationFrame, you might find newtonjs/raf better suits your needs.

Installation

This library isn't available from the NPM repository or any other package manager, but you can still add it to your package.json

{
  "dependencies": {
    "newtonjs-frame": "git://github.com/newtonjs/frame.git#master"
  }
}

Contributing

We accept contributions to the source via Pull Request, but you must run the tests and compile the JavaScript before it will be considered for merge. The source for this library is written in CoffeeScript, but it is distributed with the compiled JavaScript.

$ npm test                # Run tests
$ npm run-script compile  # Compile JavaScript

License

The content of this library is released under the MIT License by Andrew Lawson.
You can find a copy of this license at http://www.opensource.org/licenses/mit

About

Animation frame wrapper.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors