From: etimberg Date: Sun, 30 Oct 2016 15:03:19 +0000 (-0400) Subject: When an event triggers an update while the bufferedUpdate state is true, we need... X-Git-Tag: v2.4.0~1^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f288bc727b34873542faea5d50585cb842eb02f9;p=thirdparty%2FChart.js.git When an event triggers an update while the bufferedUpdate state is true, we need to do that render with priority over any other renders that take place for animations and tooltips --- diff --git a/src/core/core.animation.js b/src/core/core.animation.js index 7ccb37493..dcb9c2ee0 100644 --- a/src/core/core.animation.js +++ b/src/core/core.animation.js @@ -27,6 +27,14 @@ module.exports = function(Chart) { animations: [], dropFrames: 0, request: null, + + /** + * @function Chart.animationService.addAnimation + * @param chartInstance {ChartController} the chart to animate + * @param animationObject {IAnimation} the animation that we will animate + * @param duration {Number} length of animation in ms + * @param lazy {Boolean} if true, the chart is not marked as animating to enable more responsive interactions + */ addAnimation: function(chartInstance, animationObject, duration, lazy) { var me = this; diff --git a/src/core/core.controller.js b/src/core/core.controller.js index e0ad78334..0b644c644 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -460,7 +460,12 @@ module.exports = function(Chart) { // Do this before render so that any plugins that need final scale updates can use it Chart.plugins.notify('afterUpdate', [me]); - if (!me._bufferedRender) { + if (me._bufferedRender) { + me._bufferedRequest = { + lazy: lazy, + duration: animationDuration + }; + } else { me.render(animationDuration, lazy); } }, @@ -718,12 +723,17 @@ module.exports = function(Chart) { // Buffer any update calls so that renders do not occur me._bufferedRender = true; + me._bufferedRequest = null; var changed = me.handleEvent(e); changed |= me.legend.handleEvent(e); changed |= me.tooltip.handleEvent(e); - if (changed && !me.animating) { + var bufferedRequest = me._bufferedRequest; + if (bufferedRequest) { + // If we have an update that was triggered, we need to do a normal render + me.render(bufferedRequest.duration, bufferedRequest.lazy); + } else if (changed && !me.animating) { // If entering, leaving, or changing elements, animate the change via pivot me.stop(); @@ -733,6 +743,8 @@ module.exports = function(Chart) { } me._bufferedRender = false; + me._bufferedRequest = null; + return me; },