Travis build: 1782 [cron]

This commit is contained in:
30secondsofcode
2018-03-06 20:32:31 +00:00
parent e7c5bcf6c6
commit 536373e77b
4 changed files with 48 additions and 13 deletions

View File

@ -0,0 +1,21 @@
const recordAnimationFrames = (callback, autoStart = true) => {
let running = true,
raf;
const stop = () => {
running = false;
cancelAnimationFrame(raf);
};
const start = () => {
running = true;
run();
};
const run = () => {
raf = requestAnimationFrame(() => {
callback();
if (running) run();
});
};
if (autoStart) start();
return { start, stop };
};
module.exports = recordAnimationFrames;