From 3853921d5f22e8d35fa19f9039774ac5e7dca5fd Mon Sep 17 00:00:00 2001 From: Jecyu Date: Tue, 8 Sep 2020 09:21:24 +0800 Subject: [PATCH] Update recordAnimationFrames.md --- snippets/recordAnimationFrames.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/snippets/recordAnimationFrames.md b/snippets/recordAnimationFrames.md index 531c1f9fe..d505a5aa6 100644 --- a/snippets/recordAnimationFrames.md +++ b/snippets/recordAnimationFrames.md @@ -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(); };