/loop-fns

Functions to help with your looping needs for animated graphics and beyond.

Primary LanguageTypeScriptMIT LicenseMIT

loop-fns

A lightweight solution for looping with great performance and control.

Get started

Install

yarn add loop-fns
# or
npm install --save loop-fns

Use

import { loopFrames } from 'loop-fns'

const props = loopFrames((props) => {
  // your graphics update logic...

  // you can also control the loop within the callback
  if (props.currentFrame === 10) {
    props.stop()
  }
}, 30) // limit to 30fps

props.start()