frameDuration: 17,
animations: [],
dropFrames: 0,
+ request: null,
addAnimation: function(chartInstance, animationObject, duration, lazy) {
if (!lazy) {
// If there are no animations queued, manually kickstart a digest, for lack of a better word
if (this.animations.length === 1) {
- helpers.requestAnimFrame.call(window, this.digestWrapper);
+ this.requestAnimationFrame();
}
},
// Cancel the animation for a given chart instance
chartInstance.animating = false;
}
},
- // calls startDigest with the proper context
- digestWrapper: function() {
- Chart.animationService.startDigest.call(Chart.animationService);
+ requestAnimationFrame: function() {
+ var me = this;
+ if (me.request === null) {
+ // Skip animation frame requests until the active one is executed.
+ // This can happen when processing mouse events, e.g. 'mousemove'
+ // and 'mouseout' events will trigger multiple renders.
+ me.request = helpers.requestAnimFrame.call(window, function() {
+ me.request = null;
+ me.startDigest();
+ });
+ }
},
startDigest: function() {
// Do we have more stuff to animate?
if (this.animations.length > 0) {
- helpers.requestAnimFrame.call(window, this.digestWrapper);
+ this.requestAnimationFrame();
}
}
};