@@ -298,38 +298,37 @@ angular.module('angular-svg-round-progress')
298298 var ring = element . find ( 'path' ) ,
299299 background = element . find ( 'circle' ) ,
300300 options = angular . copy ( roundProgressConfig ) ,
301- size ,
302301 resetValue ;
303302
304303 var renderCircle = function ( ) {
305- var isSemicircle = options . semi ,
306- radius = parseInt ( options . radius ) ,
307- stroke = parseInt ( options . stroke ) ;
308-
309- size = radius * 2 + stroke * 2 ;
304+ var isSemicircle = options . semi ;
305+ var radius = parseInt ( options . radius ) || 0 ;
306+ var stroke = parseInt ( options . stroke ) ;
307+ var diameter = radius * 2 ;
308+ var backgroundSize = radius - ( stroke / 2 ) ;
310309
311310 element . css ( {
312- "width" : size + "px" ,
313- "height" : ( isSemicircle ? size / 2 : size ) + "px" ,
311+ "width" : diameter + "px" ,
312+ "height" : ( isSemicircle ? radius : diameter ) + "px" ,
314313 "overflow" : "hidden" // on some browsers the background overflows, if in semicircle mode
315314 } ) ;
316315
317316 ring . css ( {
318- "stroke" : options . color ,
319- "stroke-width" : stroke ,
320- "stroke-linecap" : options . rounded ? "round" : "butt"
317+ "stroke" : options . color ,
318+ "stroke-width" : stroke ,
319+ "stroke-linecap" : options . rounded ? "round" : "butt"
321320 } ) ;
322321
323322 if ( isSemicircle ) {
324- ring . attr ( "transform" , options . clockwise ? "translate(" + 0 + "," + size + ") rotate(-90)" : "translate(" + size + ", " + size + ") rotate(90) scale(-1, 1)" ) ;
323+ ring . attr ( "transform" , options . clockwise ? "translate(" + 0 + "," + diameter + ") rotate(-90)" : "translate(" + diameter + ", " + diameter + ") rotate(90) scale(-1, 1)" ) ;
325324 } else {
326- ring . attr ( "transform" , options . clockwise ? "" : "scale(-1, 1) translate(" + ( - size ) + " 0)" ) ;
325+ ring . attr ( "transform" , options . clockwise ? "" : "scale(-1, 1) translate(" + ( - diameter ) + " 0)" ) ;
327326 }
328327
329328 background . attr ( {
330- "cx" : radius + stroke ,
331- "cy" : radius + stroke ,
332- "r" : radius
329+ "cx" : radius ,
330+ "cy" : radius ,
331+ "r" : backgroundSize >= 0 ? backgroundSize : 0
333332 } ) . css ( {
334333 "stroke" : options . bgcolor ,
335334 "stroke-width" : stroke
@@ -351,14 +350,15 @@ angular.module('angular-svg-round-progress')
351350 return scope . current = options . max ;
352351 }
353352
354- var max = options . max ,
355- radius = options . radius ,
356- isSemicircle = options . semi ,
357- easingAnimation = service . animations [ options . animation ] ,
358- start = oldValue === newValue ? 0 : ( oldValue || 0 ) , // fixes the initial animation
359- val = newValue - start ,
360- currentIteration = 0 ,
361- totalIterations = parseInt ( options . iterations ) ;
353+ var max = options . max || 0 ;
354+ var easingAnimation = service . animations [ options . animation ] ;
355+ var start = oldValue === newValue ? 0 : ( oldValue || 0 ) ; // fixes the initial animation
356+ var val = newValue - start ;
357+ var currentIteration = 0 ;
358+ var totalIterations = parseInt ( options . iterations ) ;
359+ var radius = options . radius ;
360+ var circleSize = radius - ( options . stroke / 2 ) ;
361+ var elementSize = radius * 2 ;
362362
363363 if ( angular . isNumber ( resetValue ) ) {
364364 // the reset value fixes problems with animation, caused when limiting the scope.current
@@ -371,10 +371,10 @@ angular.module('angular-svg-round-progress')
371371 service . updateState (
372372 easingAnimation ( currentIteration , start , val , totalIterations ) ,
373373 max ,
374- radius ,
374+ circleSize ,
375375 ring ,
376- size ,
377- isSemicircle ) ;
376+ elementSize ,
377+ options . semi ) ;
378378
379379 if ( currentIteration < totalIterations ) {
380380 $window . requestAnimationFrame ( animation ) ;
0 commit comments