1.0.2 • Published 7 years ago

fps-throttler v1.0.2

Weekly downloads
7
License
Apache License 2....
Repository
github
Last release
7 years ago

FPS Throttler

Throttle function call excatly to specific number times during one second - fps limit (by using requestAnimationFrame).

Example:

const Throttler = require('fps-throttler');
const throttler = new Throttler(() => {}, 10);

This will call function 10 times per second (max limit is 60 - according to requestAnimationFrame specification).

Usage

Create new throttler:

const Throttler = require('fps-throttler');
const throttler = new Throttler(callback, fpsLimit);

For ecmascript module use:

import Throttler from './node_modules/src/fps-throttler/throttler.esm.js';

Start:

throttler.start();

Stop:

throttler.stop();

Change fps limit

throttler.limit(fps);

Change callback

throttler.callback(callable);