Merge pull request #1212 from Jecyu/update-recordAnimationFrames

Update recordAnimationFrames to avoid multiple callback invocations
This commit is contained in:
Angelos Chalaris
2020-09-08 09:39:09 +03:00
committed by GitHub

View File

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