UNPKG

@momentum-ui/react-collaboration

Version:

Cisco Momentum UI Framework for React Collaboration Applications

24 lines 797 B
import { caf, raf } from '../requestAnimationFrame'; export var cancelAnimationTimeout = function (frame) { return caf(frame.id); }; /** * Recursively calls requestAnimationFrame until a specified delay has been met or exceeded. * When the delay time has been reached the function you're timing out will be called. * * Credit: Joe Lambert (https://gist.github.com/joelambert/1002116#file-requesttimeout-js) */ export var requestAnimationTimeout = function (callback, delay) { var start = Date.now(); var timeout = function () { if (Date.now() - start >= delay) { callback.call(); } else { frame.id = raf(timeout); } }; var frame = { id: raf(timeout), }; return frame; }; //# sourceMappingURL=index.js.map