UNPKG

@pmwcs/base

Version:
23 lines (18 loc) 583 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.raf = void 0; /** * A helper for when we have multiple requestion animation frames * Usage: * raf(() => doSomething, 3); */ var raf = function raf(callback) { var frames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; var _iteration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; window.requestAnimationFrame(function () { _iteration >= frames ? callback() : raf(callback, frames, _iteration + 1); }); }; exports.raf = raf;