From: Jukka Kurkela Date: Mon, 4 Mar 2019 08:11:57 +0000 (+0200) Subject: Fix animation regression introduced by #5331 (#6108) X-Git-Tag: v2.8.0-rc.1~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=344628ba9c5fc95a1edbc9cf94488461d24a4b32;p=thirdparty%2FChart.js.git Fix animation regression introduced by #5331 (#6108) --- diff --git a/src/core/core.animations.js b/src/core/core.animations.js index 54645ddd9..df6100f5b 100644 --- a/src/core/core.animations.js +++ b/src/core/core.animations.js @@ -93,20 +93,24 @@ module.exports = { */ advance: function() { var animations = this.animations; - var animation, chart; + var animation, chart, numSteps, nextStep; var i = 0; + // 1 animation per chart, so we are looping charts here while (i < animations.length) { animation = animations[i]; chart = animation.chart; + numSteps = animation.numSteps; - animation.currentStep = Math.floor((Date.now() - animation.startTime) / animation.duration * animation.numSteps); - animation.currentStep = Math.min(animation.currentStep, animation.numSteps); + // Make sure that currentStep starts at 1 + // https://github.com/chartjs/Chart.js/issues/6104 + nextStep = Math.floor((Date.now() - animation.startTime) / animation.duration * numSteps) + 1; + animation.currentStep = Math.min(nextStep, numSteps); helpers.callback(animation.render, [chart, animation], chart); helpers.callback(animation.onAnimationProgress, [animation], chart); - if (animation.currentStep >= animation.numSteps) { + if (animation.currentStep >= numSteps) { helpers.callback(animation.onAnimationComplete, [animation], chart); chart.animating = false; animations.splice(i, 1);