@@ -33,38 +33,37 @@ angular.module('angular-svg-round-progress')
3333 var ring = element . find ( 'path' ) ,
3434 background = element . find ( 'circle' ) ,
3535 options = angular . copy ( roundProgressConfig ) ,
36- size ,
3736 resetValue ;
3837
3938 var renderCircle = function ( ) {
40- var isSemicircle = options . semi ,
41- radius = parseInt ( options . radius ) ,
42- stroke = parseInt ( options . stroke ) ;
43-
44- size = radius * 2 + stroke * 2 ;
39+ var isSemicircle = options . semi ;
40+ var radius = parseInt ( options . radius ) || 0 ;
41+ var stroke = parseInt ( options . stroke ) ;
42+ var diameter = radius * 2 ;
43+ var backgroundSize = radius - ( stroke / 2 ) ;
4544
4645 element . css ( {
47- "width" : size + "px" ,
48- "height" : ( isSemicircle ? size / 2 : size ) + "px" ,
46+ "width" : diameter + "px" ,
47+ "height" : ( isSemicircle ? radius : diameter ) + "px" ,
4948 "overflow" : "hidden" // on some browsers the background overflows, if in semicircle mode
5049 } ) ;
5150
5251 ring . css ( {
53- "stroke" : options . color ,
54- "stroke-width" : stroke ,
55- "stroke-linecap" : options . rounded ? "round" : "butt"
52+ "stroke" : options . color ,
53+ "stroke-width" : stroke ,
54+ "stroke-linecap" : options . rounded ? "round" : "butt"
5655 } ) ;
5756
5857 if ( isSemicircle ) {
59- ring . attr ( "transform" , options . clockwise ? "translate(" + 0 + "," + size + ") rotate(-90)" : "translate(" + size + ", " + size + ") rotate(90) scale(-1, 1)" ) ;
58+ ring . attr ( "transform" , options . clockwise ? "translate(" + 0 + "," + diameter + ") rotate(-90)" : "translate(" + diameter + ", " + diameter + ") rotate(90) scale(-1, 1)" ) ;
6059 } else {
61- ring . attr ( "transform" , options . clockwise ? "" : "scale(-1, 1) translate(" + ( - size ) + " 0)" ) ;
60+ ring . attr ( "transform" , options . clockwise ? "" : "scale(-1, 1) translate(" + ( - diameter ) + " 0)" ) ;
6261 }
6362
6463 background . attr ( {
65- "cx" : radius + stroke ,
66- "cy" : radius + stroke ,
67- "r" : radius
64+ "cx" : radius ,
65+ "cy" : radius ,
66+ "r" : backgroundSize >= 0 ? backgroundSize : 0
6867 } ) . css ( {
6968 "stroke" : options . bgcolor ,
7069 "stroke-width" : stroke
@@ -86,14 +85,15 @@ angular.module('angular-svg-round-progress')
8685 return scope . current = options . max ;
8786 }
8887
89- var max = options . max ,
90- radius = options . radius ,
91- isSemicircle = options . semi ,
92- easingAnimation = service . animations [ options . animation ] ,
93- start = oldValue === newValue ? 0 : ( oldValue || 0 ) , // fixes the initial animation
94- val = newValue - start ,
95- currentIteration = 0 ,
96- totalIterations = parseInt ( options . iterations ) ;
88+ var max = options . max || 0 ;
89+ var easingAnimation = service . animations [ options . animation ] ;
90+ var start = oldValue === newValue ? 0 : ( oldValue || 0 ) ; // fixes the initial animation
91+ var val = newValue - start ;
92+ var currentIteration = 0 ;
93+ var totalIterations = parseInt ( options . iterations ) ;
94+ var radius = options . radius ;
95+ var circleSize = radius - ( options . stroke / 2 ) ;
96+ var elementSize = radius * 2 ;
9797
9898 if ( angular . isNumber ( resetValue ) ) {
9999 // the reset value fixes problems with animation, caused when limiting the scope.current
@@ -106,10 +106,10 @@ angular.module('angular-svg-round-progress')
106106 service . updateState (
107107 easingAnimation ( currentIteration , start , val , totalIterations ) ,
108108 max ,
109- radius ,
109+ circleSize ,
110110 ring ,
111- size ,
112- isSemicircle ) ;
111+ elementSize ,
112+ options . semi ) ;
113113
114114 if ( currentIteration < totalIterations ) {
115115 $window . requestAnimationFrame ( animation ) ;
0 commit comments