From 4bf19b41caafaf35abc537b93bddd23990f796c8 Mon Sep 17 00:00:00 2001 From: Dzmirty Luhauskoi Date: Thu, 20 Sep 2018 12:29:17 +0300 Subject: [PATCH] fps must not be a divisor of 60 fix --- canvid.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/canvid.js b/canvid.js index 67c405b..3b0afd4 100644 --- a/canvid.js +++ b/canvid.js @@ -15,6 +15,7 @@ selector: '.canvid-wrapper' }, firstPlay = true, + lastWait = 0, control = { play: function() { console.log('Cannot play before images are loaded'); @@ -97,7 +98,7 @@ } function frame() { - if (!wait) { + if (lastWait > wait) { drawFrame(curFrame); curFrame = (+curFrame + (reverse ? -1 : 1)); if (curFrame < 0) curFrame += +opts.frames; @@ -110,6 +111,7 @@ } } } + lastWait = wait; wait = (wait + 1) % delay; if (playing && opts.frames > 1) requestAnimationFrame(frame); }