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

runfor

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

runfor

Run a performant function for a period of time

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
14
366.67%
Maintainers
1
Weekly downloads
 
Created
Source

runFor(fn, ms)

npm version

Run a performant function for a period of time

Run requestAnimationFrame for the specified duration.

Install

npm install --save runfor

or

yarn add runfor

Usage

runFor(progressFn, msDuration);

Example

import runFor from 'runfor';

function moveX(progress) {
	// Move right 200px
  div.style.transform = `translateX(${progress * 200}px`;
}

// Run moveX for 1sec with a progress between 0 and 1.
runFor(p => moveX(p), 1000);

Check the examples/ folder to see full examples.

API

Optionally you can stop or start the animation with this functions:

const runner = runFor(fn, 1000);

runner.toggle()
runner.stop()
runner.start()

.stop()

Stops the animation.

.start()

Starts the animation keeping the previous progress.

.toggle()

Toggle start / stop.

.restart()

Restart animation from the beginning

Development

yarn install

yarn run dev

Test

yarn test

Keywords

animation

FAQs

Package last updated on 16 Sep 2017

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