You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

reraf

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reraf

A super light and simple way to reschedule animation frames

1.1.1
latest
npmnpm
Version published
Weekly downloads
3.7K
-27.6%
Maintainers
1
Weekly downloads
 
Created
Source

reraf

Build Status Coverage Status

Social Media Photo by Hans Eiskonen on Unsplash

A super light and simple way to reschedule animation frames, compatible with every browser and Node.js through a setTimeout and clearTimeout fallback.

import reraf from 'reraf';
// or const reraf = require('reraf');
// or <script src="//unpkg.com/reraf">

const reschedule = reraf(/* optional integer limit */);

reschedule(console.log, null, ['first']);
reschedule(console.log, null, ['second']);
// will log "second", but never "first"

The reschedule(...) returns a function to be able to stop() the scheduled animation frame, in case it's needed.

If a truthy value is passed to stop(truthy), the callback will be "flushed" (invoked) if it didn't flush already.

The stop(...) function returns a boolean value, indicating the stop actually stopped the execution of the callback, or it didn't, 'cause it happened before.

Keywords

requestAnimationFrame

FAQs

Package last updated on 05 Nov 2019

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