From: Tanner Linsley Date: Mon, 3 Aug 2015 23:17:49 +0000 (-0600) Subject: More Accurate animation frame dropper X-Git-Tag: 2.0.0-alpha4~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26c210db33ccce675c428f5f67f296de3b4c8a97;p=thirdparty%2FChart.js.git More Accurate animation frame dropper --- diff --git a/src/core/core.animation.js b/src/core/core.animation.js index a61f5e0a1..cb6c6fc0a 100644 --- a/src/core/core.animation.js +++ b/src/core/core.animation.js @@ -73,7 +73,7 @@ if (this.dropFrames > 1) { framesToDrop = Math.floor(this.dropFrames); - this.dropFrames -= framesToDrop; + this.dropFrames = this.dropFrames % 1; } for (var i = 0; i < this.animations.length; i++) { @@ -81,7 +81,6 @@ if (this.animations[i].animationObject.currentStep === null) { this.animations[i].animationObject.currentStep = 0; } - this.animations[i].animationObject.currentStep += 1 + framesToDrop; if (this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps) { this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; @@ -99,12 +98,9 @@ } var endTime = Date.now(); - var delay = endTime - startTime - this.frameDuration; - var frameDelay = delay / this.frameDuration; + var dropFrames = (endTime - startTime) / this.frameDuration; - if (frameDelay > 1) { - this.dropFrames += frameDelay; - } + this.dropFrames += dropFrames; // Do we have more stuff to animate? if (this.animations.length > 0) {