Update recordAnimationFrames.md
This commit is contained in:
@ -12,13 +12,15 @@ Omit the second argument, `autoStart`, to implicitly call `start` when the funct
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const recordAnimationFrames = (callback, autoStart = true) => {
|
const recordAnimationFrames = (callback, autoStart = true) => {
|
||||||
let running = true,
|
let running = false,
|
||||||
raf;
|
raf;
|
||||||
const stop = () => {
|
const stop = () => {
|
||||||
|
if (!running) return;
|
||||||
running = false;
|
running = false;
|
||||||
cancelAnimationFrame(raf);
|
cancelAnimationFrame(raf);
|
||||||
};
|
};
|
||||||
const start = () => {
|
const start = () => {
|
||||||
|
if (running) return;
|
||||||
running = true;
|
running = true;
|
||||||
run();
|
run();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user