From 82845864805909efb92ea4fbe44a15608d8d9106 Mon Sep 17 00:00:00 2001 From: Eric Harrison Date: Tue, 25 Jun 2013 13:49:10 -0700 Subject: [PATCH] added ability to set the animation to be percentage of the whole --- jquery.easy-pie-chart.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jquery.easy-pie-chart.js b/jquery.easy-pie-chart.js index 6662b01..179a3ae 100644 --- a/jquery.easy-pie-chart.js +++ b/jquery.easy-pie-chart.js @@ -136,18 +136,20 @@ Thanks to Philip Thrasher for the jquery plugin boilerplate for coffee script _this.percentage = to; startTime = Date.now(); anim = function() { - var currentValue, process; + var currentValue, process, animationTime; + + animationTime = _this.options.animatePercentOf ? (_this.options.animate * (_this.percentage / 100 )) : _this.options.animate; process = Date.now() - startTime; - if (process < _this.options.animate) { + if (process < animationTime) { rAF(anim); } _this.ctx.clearRect(-_this.options.size / 2, -_this.options.size / 2, _this.options.size, _this.options.size); renderBackground.call(_this); - currentValue = [easeInOutQuad(process, from, to - from, _this.options.animate)]; + currentValue = [easeInOutQuad(process, from, to - from, animationTime)]; _this.options.onStep.call(_this, currentValue); drawLine.call(_this, currentValue); - if (process >= _this.options.animate) { + if (process >= animationTime) { return _this.options.onStop.call(_this); } }; @@ -180,6 +182,7 @@ Thanks to Philip Thrasher for the jquery plugin boilerplate for coffee script size: 110, lineWidth: 3, animate: false, + animatePercentOf: false, onStart: $.noop, onStop: $.noop, onStep: $.noop