]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Implement cancel animation frame in the animation service
authorEvert Timberg <evert.timberg@gmail.com>
Sun, 12 Apr 2015 00:17:46 +0000 (20:17 -0400)
committerEvert Timberg <evert.timberg@gmail.com>
Sun, 12 Apr 2015 00:17:46 +0000 (20:17 -0400)
src/Chart.Core.js

index 7e48ead008be01bb60164306de25360f0b271552..565ceeeb1da8d2fc6c0deca336d2c7dda3c7cd62 100755 (executable)
                },
                stop : function(){
                        // Stops any current animation loop occuring
-                       cancelAnimFrame(this.animationFrame);
+                       Chart.animationService.cancelAnimation(this);
                        return this;
                },
                resize : function(callback){
                                helpers.requestAnimFrame.call(window, this.digestWrapper);
                        }
                },
+               // Cancel the animation for a given chart instance
+               cancelAnimation: function(chartInstance) {
+                       var index = helpers.findNextWhere(this.animations, function(animationWrapper) {
+                               return animationWrapper.chartInstance === chartInstance;
+                       });
+                       
+                       if (index != -1)
+                       {
+                               this.animations.splice(index, 1);
+                       }
+               },
                // calls startDigest with the proper context
                digestWrapper: function() {
                        Chart.animationService.startDigest.call(Chart.animationService);