Skip to content

Commit 5d185e5

Browse files
committed
More robust fallback for performance.now and bump to 0.4.2
1 parent 2815a30 commit 5d185e5

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
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.4.1",
3+
"version": "0.4.2",
44
"homepage": "https://github.com/crisbeto/angular-svg-round-progressbar",
55
"authors": [
66
"crisbeto"

build/roundProgress.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* [email protected].1 2016-03-24 */
1+
/* [email protected].2 2016-03-30 */
22
// shim layer with setTimeout fallback
33
// credit Erik Möller and http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
44
'use strict';
@@ -104,10 +104,10 @@ angular.module('angular-svg-round-progressbar').service('roundProgressService',
104104
return value;
105105
};
106106

107-
service.getTimestamp = $window.performance && $window.performance.now ? function(){
107+
service.getTimestamp = ($window.performance && $window.performance.now && angular.isNumber($window.performance.now())) ? function(){
108108
return $window.performance.now();
109109
} : function(){
110-
return $window.Date.now();
110+
return new $window.Date().getTime();
111111
};
112112

113113
// credit to http://stackoverflow.com/questions/5736398/how-to-calculate-the-svg-path-for-an-arc-of-a-circle
@@ -447,8 +447,8 @@ angular.module('angular-svg-round-progressbar').directive('roundProgress', ['$wi
447447
var startTime = service.getTimestamp();
448448
var id = ++lastAnimationId;
449449

450-
$window.requestAnimationFrame(function animation(now){
451-
var currentTime = $window.Math.min((now || service.getTimestamp()) - startTime, duration);
450+
$window.requestAnimationFrame(function animation(){
451+
var currentTime = $window.Math.min(service.getTimestamp() - startTime, duration);
452452
var animateTo = easingAnimation(currentTime, start, changeInValue, duration);
453453

454454
service.updateState(animateTo, max, circleSize, ring, radius, isSemicircle);

build/roundProgress.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.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.4.1",
3+
"version": "0.4.2",
44
"description": "AngularJS module that uses SVG to create a circular progressbar",
55
"main": "build/roundProgress.min.js",
66
"scripts": {},

src/roundProgress.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ angular.module('angular-svg-round-progressbar').directive('roundProgress', ['$wi
124124
var startTime = service.getTimestamp();
125125
var id = ++lastAnimationId;
126126

127-
$window.requestAnimationFrame(function animation(now){
128-
var currentTime = $window.Math.min((now || service.getTimestamp()) - startTime, duration);
127+
$window.requestAnimationFrame(function animation(){
128+
var currentTime = $window.Math.min(service.getTimestamp() - startTime, duration);
129129
var animateTo = easingAnimation(currentTime, start, changeInValue, duration);
130130

131131
service.updateState(animateTo, max, circleSize, ring, radius, isSemicircle);

0 commit comments

Comments
 (0)