@@ -199,13 +199,13 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming,
199199 path . attr ( 'stroke-width' , strokeWidth ) ;
200200 path . attr ( 'stroke-linecap' , 'square' ) ;
201201 if ( scope . mdMode == MODE_INDETERMINATE ) {
202- path . attr ( 'd' , getSvgArc ( diameter , true ) ) ;
203- path . attr ( 'stroke-dasharray' , diameter * $window . Math . PI * 0.75 ) ;
204- path . attr ( 'stroke-dashoffset' , getDashLength ( diameter , 1 , 75 ) ) ;
202+ path . attr ( 'd' , getSvgArc ( diameter , strokeWidth , true ) ) ;
203+ path . attr ( 'stroke-dasharray' , ( diameter - strokeWidth ) * $window . Math . PI * 0.75 ) ;
204+ path . attr ( 'stroke-dashoffset' , getDashLength ( diameter , strokeWidth , 1 , 75 ) ) ;
205205 } else {
206- path . attr ( 'd' , getSvgArc ( diameter , false ) ) ;
207- path . attr ( 'stroke-dasharray' , diameter * $window . Math . PI ) ;
208- path . attr ( 'stroke-dashoffset' , getDashLength ( diameter , 0 , 100 ) ) ;
206+ path . attr ( 'd' , getSvgArc ( diameter , strokeWidth , false ) ) ;
207+ path . attr ( 'stroke-dasharray' , ( diameter - strokeWidth ) * $window . Math . PI ) ;
208+ path . attr ( 'stroke-dashoffset' , getDashLength ( diameter , strokeWidth , 0 , 100 ) ) ;
209209 renderCircle ( value , value ) ;
210210 }
211211
@@ -216,6 +216,7 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming,
216216 var startTime = $mdUtil . now ( ) ;
217217 var changeInValue = animateTo - animateFrom ;
218218 var diameter = getSize ( scope . mdDiameter ) ;
219+ var strokeWidth = getStroke ( diameter ) ;
219220 var ease = easing || $mdProgressCircular . easeFn ;
220221 var animationDuration = duration || $mdProgressCircular . duration ;
221222 var rotation = - 90 * ( iterationCount || 0 ) ;
@@ -238,7 +239,7 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming,
238239 }
239240
240241 function renderFrame ( value ) {
241- path . attr ( 'stroke-dashoffset' , getDashLength ( diameter , value , dashLimit ) ) ;
242+ path . attr ( 'stroke-dashoffset' , getDashLength ( diameter , strokeWidth , value , dashLimit ) ) ;
242243 path . attr ( 'transform' , 'rotate(' + ( rotation ) + ' ' + diameter / 2 + ' ' + diameter / 2 + ')' ) ;
243244 }
244245 }
@@ -291,28 +292,34 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming,
291292 * Syntax spec: https://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
292293 *
293294 * @param {number } diameter Diameter of the container.
295+ * @param {number } strokeWidth Stroke width to be used when drawing circle
294296 * @param {boolean } indeterminate Use if progress circle will be used for indeterminate
295297 *
296298 * @returns {string } String representation of an SVG arc.
297299 */
298- function getSvgArc ( diameter , indeterminate ) {
300+ function getSvgArc ( diameter , strokeWidth , indeterminate ) {
299301 var radius = diameter / 2 ;
300- return 'M' + radius + ',0'
301- + 'A' + radius + ',' + radius + ' 0 1 1 0,' + radius // 75% circle
302- + ( indeterminate ? '' : 'A' + radius + ',' + radius + ' 0 0 1 ' + radius + ',0' ) ;
302+ var offset = strokeWidth / 2 ;
303+ var start = radius + ',' + offset ; // ie: (25, 2.5) or 12 o'clock
304+ var end = offset + ',' + radius ; // ie: (2.5, 25) or 9 o'clock
305+ var arcRadius = radius - offset ;
306+ return 'M' + start
307+ + 'A' + arcRadius + ',' + arcRadius + ' 0 1 1 ' + end // 75% circle
308+ + ( indeterminate ? '' : 'A' + arcRadius + ',' + arcRadius + ' 0 0 1 ' + start ) ; // loop to start
303309 }
304310
305311 /**
306312 * Return stroke length for progress circle
307313 *
308314 * @param {number } diameter Diameter of the container.
315+ * @param {number } strokeWidth Stroke width to be used when drawing circle
309316 * @param {number } value Percentage of circle (between 0 and 100)
310317 * @param {number } limit Max percentage for circle
311318 *
312319 * @returns {number } Stroke length for progres circle
313320 */
314- function getDashLength ( diameter , value , limit ) {
315- return diameter * $window . Math . PI * ( ( 3 * ( limit || 100 ) / 100 ) - ( value / 100 ) ) ;
321+ function getDashLength ( diameter , strokeWidth , value , limit ) {
322+ return ( diameter - strokeWidth ) * $window . Math . PI * ( ( 3 * ( limit || 100 ) / 100 ) - ( value / 100 ) ) ;
316323 }
317324
318325 /**
0 commit comments