]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
More Accurate animation frame dropper
authorTanner Linsley <tannerlinsley@gmail.com>
Mon, 3 Aug 2015 23:17:49 +0000 (17:17 -0600)
committerTanner Linsley <tannerlinsley@gmail.com>
Mon, 3 Aug 2015 23:17:49 +0000 (17:17 -0600)
src/core/core.animation.js

index a61f5e0a14acdb7d0737a33095267f3ced6762bd..cb6c6fc0ad10f98b16e2893c95748e5e02b61a16 100644 (file)
@@ -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;
                        }
 
                        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) {