UNPKG

@pmwcs/base

Version:
15 lines (14 loc) 310 B
/** * A helper for when we have multiple requestion animation frames * Usage: * raf(() => doSomething, 3); */ export const raf = ( callback, frames = 1, _iteration = 1 ) => { window.requestAnimationFrame(() => { _iteration >= frames ? callback() : raf(callback, frames, _iteration + 1) }) }