From 2c609736798aa9abb91700b2b248fac5ad02b6f5 Mon Sep 17 00:00:00 2001 From: 7ever Date: Thu, 27 Mar 2014 18:03:58 +0200 Subject: [PATCH] Added method to stop animation --- src/renderer/canvas.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/renderer/canvas.js b/src/renderer/canvas.js index 8372c86..f70536b 100644 --- a/src/renderer/canvas.js +++ b/src/renderer/canvas.js @@ -163,6 +163,10 @@ var CanvasRenderer = function(el, options) { // draw bar drawCircle(color, options.lineWidth, percent / 100); + + // store value + options.value = percent; + }.bind(this); /** @@ -178,7 +182,7 @@ var CanvasRenderer = function(el, options) { var currentValue = options.easing(this, process, from, to - from, options.animate.duration); this.draw(currentValue); options.onStep(from, to, currentValue); - if (process >= options.animate.duration) { + if (options.animate.stopped || process >= options.animate.duration) { options.onStop(from, to); } else { reqAnimationFrame(animation); @@ -187,4 +191,11 @@ var CanvasRenderer = function(el, options) { reqAnimationFrame(animation); }.bind(this); + + /** + * Stop animation + */ + this.stop = function () { + options.animate.stopped = true; + }; };