animation-frame-delta
TypeScript icon, indicating that this package has built-in type declarations

2.8.6 • Public • Published

Animation frame delta

Example

Register a animation loop like so

import animFrame from "animation-frame-delta"

animFrame((delta, timestamp, absoluteDelta) => {
  console.log(delta)          // 1 at 60fps
  console.log(timestamp)      // progressing timestamp
  console.log(absoluteDelta)  // 16.6666 at 60fps
})

When given a duration, the progress is beeing passed to the individual function.

let duration = 1000

let subscription = animFrame((progress, delta, timestamp, absoluteDelta) => {
  console.log(progress)       // 0..1000
}, duration)

To cancel simply call

subscription.cancel()

An elapsing subscription can also be iterated a number of times

let iterate = 3

let subscription = animFrame((progress) => {
  console.log(progress)       // 0..1000 ; 0..1000 ; 0..1000
}, duration, iterate)

Conribute

All feedback is appreciated. Create an pull request or write an issue.

Package Sidebar

Install

npm i animation-frame-delta

Weekly Downloads

27

Version

2.8.6

License

ISC

Unpacked Size

28.9 kB

Total Files

12

Last publish

Collaborators

  • zzrv