raf-loop

a minimal requestAnimationFrame render loop

MIT 6 个版本
安装
npm install raf-loop
yarn add raf-loop
pnpm add raf-loop
bun add raf-loop
README

raf-loop

stable

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

var loop = require('raf-loop')

var engine = loop(function(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.

版本列表
1.1.3 2015-05-29
1.1.2 2015-05-24
1.1.1 2015-05-20
1.1.0 2015-05-09
1.0.1 2014-12-05
1.0.0 2014-12-05