1.0.0 • Published 6 years ago

raf-iterator v1.0.0

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
6 years ago

raf-iterator

requestAnimationFrame as an async iterator

Install - Usage - License: Apache-2.0

npm travis standard

Install

npm install raf-iterator

Usage

const rafIterator = require('raf-iterator')

for await (const tick of rafIterator()) {
  draw(tick)
  if (ended) {
    break
  }
}

API

rafIterator()

Returns an Async Iterator that can be used in a for await loop. Each iteration yields an incrementing tick integer. Iterations occur at the speed of requestAnimationFrame ticks, about 60fps.

breaking from the loop prevents further animation frame requests.

License

Apache-2.0