UNPKG

@pmwcs/base

Version:
10 lines 304 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); }); };