New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

intervalometer

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intervalometer

Call a function at every frame or every X ms. With start/stop

latest
Source
npmnpm
Version
1.0.6
Version published
Weekly downloads
1.8K
-10.6%
Maintainers
1
Weekly downloads
 
Created
Source

intervalometer

Call a function at every frame or every X ms. With start/stop

gzipped size Travis build npm link

Usage

There are two times of intervalometers: frame-based and time-based. Both return an object with start and stop functions. You can safely call start multiple times, the callback will only run once at every interval.

frameIntervalometer(cb)

Uses requestAnimationFrame and therefore calls the provided callback at every frame. Ideal for animations

const painter = frameIntervalometer(function (millisecondsSinceLastFrame) {
	// your logic to run at every frame
});

button.onclick = function () {
	painter.start();
};

timerIntervalometer(cb, ms)

uses setTimeout and calls the callback every ms milliseconds

const poller = timerIntervalometer(pollingFunction, 100); //runs every 100 ms

startButton.onclick = function () {
	poller.start();
};
stopButton.onclick = function () {
	poller.stop();
};

Install

Pick your favorite:

<script src="dist/intervalometer.browser.js"></script>
<!-- use as intervalometer.frameIntervalometer(cb) -->
<!--     or intervalometer.timerIntervalometer(cb, ms) -->
npm install --save intervalometer
var i = require('intervalometer');
var frameIntervalometer = i.frameIntervalometer;
var timerIntervalometer = i.timerIntervalometer;
import {frameIntervalometer, timerIntervalometer} from 'intervalometer';

Dependencies

None! frameIntervalometer only works where window.requestAnimationFrame is available (yes in modern browsers; not in Node)

  • iphone-inline-video: video[playsinline] polyfill that uses this module.
  • animate-prop: Single low-level function to tween any property over time.

License

MIT © Federico Brigante

Keywords

frame

FAQs

Package last updated on 21 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts