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;
// 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);
}
},
// 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();
}
me._bufferedRender = false;
+ me._bufferedRequest = null;
+
return me;
},