Skip to content

Commit 8fa89bd

Browse files
committed
bump the version, build the files
1 parent 3941062 commit 8fa89bd

File tree

4 files changed

+40
-28
lines changed

4 files changed

+40
-28
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-svg-round-progressbar",
3-
"version": "0.3.8",
3+
"version": "0.3.9",
44
"homepage": "https://github.com/crisbeto/angular-svg-round-progressbar",
55
"authors": [
66
"crisbeto"

build/roundProgress.js

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* [email protected].8 2015-10-21 */
1+
/* [email protected].9 2015-12-27 */
22
// shim layer with setTimeout fallback
33
// credit Erik Möller and http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
44
'use strict';
@@ -47,6 +47,7 @@ angular.module('angular-svg-round-progress').constant('roundProgressConfig', {
4747
stroke: 15,
4848
duration: 800,
4949
animation: "easeOutCubic",
50+
animationDelay: 0,
5051
offset: 0
5152
});
5253

@@ -336,7 +337,8 @@ angular.module('angular-svg-round-progress')
336337
stroke: "@",
337338
duration: "@",
338339
animation: "@",
339-
offset: "@"
340+
offset: "@",
341+
animationDelay: "@"
340342
}
341343
};
342344

@@ -354,7 +356,8 @@ angular.module('angular-svg-round-progress')
354356
var ring = svg.find('path').eq(0);
355357
var background = svg.find('circle').eq(0);
356358
var options = angular.copy(roundProgressConfig);
357-
var lastAnimationId;
359+
var lastAnimationId = 0;
360+
var lastTimeoutId;
358361
var parentChangedListener;
359362

360363
scope.getOptions = function(){
@@ -426,7 +429,6 @@ angular.module('angular-svg-round-progress')
426429
var changeInValue = end - start;
427430

428431
var easingAnimation = service.animations[options.animation];
429-
var startTime = new $window.Date();
430432
var duration = +options.duration || 0;
431433
var preventAnimation = preventAnimationOverride || (newValue > max && oldValue > max) || (newValue < 0 && oldValue < 0) || duration < 25;
432434

@@ -435,27 +437,37 @@ angular.module('angular-svg-round-progress')
435437
var elementSize = radius*2;
436438
var isSemicircle = options.semi;
437439

438-
// stops some expensive animating if the value is above the max or under 0
439-
if(preventAnimation){
440-
service.updateState(end, max, circleSize, ring, elementSize, isSemicircle);
440+
var doAnimation = function(){
441+
// stops some expensive animating if the value is above the max or under 0
442+
if(preventAnimation){
443+
service.updateState(end, max, circleSize, ring, elementSize, isSemicircle);
444+
}else{
445+
var startTime = new $window.Date();
446+
var id = ++lastAnimationId;
447+
448+
(function animation(){
449+
var currentTime = $window.Math.min(new Date() - startTime, duration);
450+
451+
service.updateState(
452+
easingAnimation(currentTime, start, changeInValue, duration),
453+
max,
454+
circleSize,
455+
ring,
456+
elementSize,
457+
isSemicircle);
458+
459+
if(id === lastAnimationId && currentTime < duration){
460+
$window.requestAnimationFrame(animation);
461+
}
462+
})();
463+
}
464+
};
465+
466+
if(options.animationDelay > 0){
467+
$window.clearTimeout(lastTimeoutId);
468+
$window.setTimeout(doAnimation, options.animationDelay);
441469
}else{
442-
$window.cancelAnimationFrame(lastAnimationId);
443-
444-
(function animation(){
445-
var currentTime = $window.Math.min(new Date() - startTime, duration);
446-
447-
service.updateState(
448-
easingAnimation(currentTime, start, changeInValue, duration),
449-
max,
450-
circleSize,
451-
ring,
452-
elementSize,
453-
isSemicircle);
454-
455-
if(currentTime < duration){
456-
lastAnimationId = $window.requestAnimationFrame(animation);
457-
}
458-
})();
470+
doAnimation();
459471
}
460472
};
461473

0 commit comments

Comments
 (0)