@@ -77,17 +77,17 @@ angular.module('angular-svg-round-progress').service('roundProgressService', [fu
7777
7878 if ( ! size ) return ring ;
7979
80- var value = val >= total ? total - 0.00001 : val ,
81- type = isSemicircle ? 180 : 359.9999 ,
82- perc = total === 0 ? 0 : ( value / total ) * type ,
83- x = size / 2 ,
84- start = polarToCartesian ( x , x , R , perc ) , // in this case x and y are the same
85- end = polarToCartesian ( x , x , R , 0 ) ,
86- arcSweep = ( perc <= 180 ? "0" : "1" ) ,
87- d = [
88- "M" , start . x , start . y ,
89- "A" , R , R , 0 , arcSweep , 0 , end . x , end . y
90- ] . join ( " " ) ;
80+ var value = val >= total ? total - 0.00001 : val ;
81+ var type = isSemicircle ? 180 : 359.9999 ;
82+ var perc = total === 0 ? 0 : ( value / total ) * type ;
83+ var x = size / 2 ;
84+ var start = polarToCartesian ( x , x , R , perc ) ; // in this case x and y are the same
85+ var end = polarToCartesian ( x , x , R , 0 ) ;
86+ var arcSweep = ( perc <= 180 ? "0" : "1" ) ;
87+ var d = [
88+ "M" , start . x , start . y ,
89+ "A" , R , R , 0 , arcSweep , 0 , end . x , end . y
90+ ] . join ( " " ) ;
9191
9292 return ring . attr ( 'd' , d ) ;
9393 } ;
@@ -382,7 +382,7 @@ angular.module('angular-svg-round-progress')
382382 $window . cancelAnimationFrame ( lastAnimationId ) ;
383383
384384 ( function animation ( ) {
385- var currentTime = new Date ( ) - startTime ;
385+ var currentTime = $window . Math . min ( new Date ( ) - startTime , duration ) ;
386386
387387 service . updateState (
388388 easingAnimation ( currentTime , start , changeInValue , duration ) ,
@@ -399,17 +399,24 @@ angular.module('angular-svg-round-progress')
399399 }
400400 } ;
401401
402- scope . $watchCollection ( '[' + Object . keys ( base . scope ) . join ( ',' ) + ']' , function ( newValue , oldValue , scope ) {
403- // pretty much the same as angular.extend,
404- // but this skips undefined values and internal angular keys
405- angular . forEach ( scope , function ( value , key ) {
406- // note the scope !== value is because `this` is part of the scope
407- if ( key . indexOf ( '$' ) && scope !== value && angular . isDefined ( value ) ) {
408- options [ key ] = value ;
402+ var keys = Object . keys ( base . scope ) . filter ( function ( key ) {
403+ return key !== 'current' ;
404+ } ) ;
405+
406+ // properties that are used only for presentation
407+ scope . $watchGroup ( keys , function ( newValue ) {
408+ for ( var i = 0 ; i < newValue . length ; i ++ ) {
409+ if ( typeof newValue [ i ] !== 'undefined' ) {
410+ options [ keys [ i ] ] = newValue [ i ] ;
409411 }
410- } ) ;
412+ }
411413
412414 renderCircle ( ) ;
415+ } ) ;
416+
417+ // properties that are used during animation. some of these overlap with
418+ // the ones that are used for presentation
419+ scope . $watchGroup ( [ 'current' , 'max' , 'animation' , 'duration' , 'radius' , 'stroke' , 'semi' ] , function ( newValue , oldValue ) {
413420 renderState ( service . toNumber ( newValue [ 0 ] ) , service . toNumber ( oldValue [ 0 ] ) ) ;
414421 } ) ;
415422 } ,
0 commit comments