Travis build: 1778

This commit is contained in:
30secondsofcode
2018-03-06 07:12:50 +00:00
parent 5423c52198
commit 1bba307091
3 changed files with 90 additions and 15 deletions

View File

@ -9,24 +9,25 @@ Omit the second argument, `autoStart`, to implicitly call `start` when the funct
```js
const recordAnimationFrames = (callback, autoStart = true) => {
let running = true, raf
let running = true,
raf;
const stop = () => {
running = false
cancelAnimationFrame(raf)
}
running = false;
cancelAnimationFrame(raf);
};
const start = () => {
running = true
run()
}
running = true;
run();
};
const run = () => {
raf = requestAnimationFrame(() => {
callback()
if (running) run()
})
}
if (autoStart) start()
return { start, stop }
}
callback();
if (running) run();
});
};
if (autoStart) start();
return { start, stop };
};
```
```js