Nuns Practicing Misanthropy
Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

raf-pause

0.0.2 • Public • Published

Installation

$ npm i raf-pause

or

$ yard add raf-pause

API

start()

Start the timer.

clean()

Clean the timer.

Recipes

import rafPause from 'raf-pause'
 
const run = rafPause(() => {
  // do something
}, 500)
run.start()
 
 
const runAndLoop = rafPause(() => {
  // do something in loop
  runAndLoop.start()
}, 500)
 
runAndLoop.start()

In React

import rafPause from 'raf-pause'
 
componentDidMount() {
  this.countDown.start()
}
 
componentWillUnMount() {
  this.countDown.clean()
}
 
countDown = rafPause(() => {
  this.setState({
    ...
  }, this.countDown)
}, 1000)
 

Fallback

It'll fallback to setTimeout if browsers don't support requestAnimationFrame

install

npm i raf-pause

Downloadsweekly downloads

1

version

0.0.2

license

MIT

last publish

collaborators

  • avatar
Report a vulnerability