Skip to content

mattdesl/raf-loop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

9c60c8a · Sep 16, 2018

History

13 Commits
Dec 5, 2014
Dec 5, 2014
Dec 5, 2014
Sep 16, 2018
May 24, 2015
May 29, 2015
Dec 5, 2014

Repository files navigation

raf-loop

stable

A minimal requestAnimationFrame render loop for node and the browser, using high-performance timing where possible.

const loop = require('raf-loop')

const engine = loop((dt) => {
    // delta time in milliseconds 
}).start()

Usage

NPM

engine = loop([fn])

Creates a new loop with an optional function to receive tick events. The function will be called with delta time as the first parameter, in milliseconds.

engine.start()

Starts the render loop and returns this engine, for chaining.

engine.stop()

Stops the render loop and cancels the currently requested animation frame.

engine.on('tick', fn)

Attaches another function to the render loop.

License

MIT, see LICENSE.md for details.