@@ -199,13 +199,13 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming,
199
199
path . attr ( 'stroke-width' , strokeWidth ) ;
200
200
path . attr ( 'stroke-linecap' , 'square' ) ;
201
201
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 ) ) ;
205
205
} 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 ) ) ;
209
209
renderCircle ( value , value ) ;
210
210
}
211
211
@@ -216,6 +216,7 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming,
216
216
var startTime = $mdUtil . now ( ) ;
217
217
var changeInValue = animateTo - animateFrom ;
218
218
var diameter = getSize ( scope . mdDiameter ) ;
219
+ var strokeWidth = getStroke ( diameter ) ;
219
220
var ease = easing || $mdProgressCircular . easeFn ;
220
221
var animationDuration = duration || $mdProgressCircular . duration ;
221
222
var rotation = - 90 * ( iterationCount || 0 ) ;
@@ -238,7 +239,7 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming,
238
239
}
239
240
240
241
function renderFrame ( value ) {
241
- path . attr ( 'stroke-dashoffset' , getDashLength ( diameter , value , dashLimit ) ) ;
242
+ path . attr ( 'stroke-dashoffset' , getDashLength ( diameter , strokeWidth , value , dashLimit ) ) ;
242
243
path . attr ( 'transform' , 'rotate(' + ( rotation ) + ' ' + diameter / 2 + ' ' + diameter / 2 + ')' ) ;
243
244
}
244
245
}
@@ -291,28 +292,34 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming,
291
292
* Syntax spec: https://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
292
293
*
293
294
* @param {number } diameter Diameter of the container.
295
+ * @param {number } strokeWidth Stroke width to be used when drawing circle
294
296
* @param {boolean } indeterminate Use if progress circle will be used for indeterminate
295
297
*
296
298
* @returns {string } String representation of an SVG arc.
297
299
*/
298
- function getSvgArc ( diameter , indeterminate ) {
300
+ function getSvgArc ( diameter , strokeWidth , indeterminate ) {
299
301
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
303
309
}
304
310
305
311
/**
306
312
* Return stroke length for progress circle
307
313
*
308
314
* @param {number } diameter Diameter of the container.
315
+ * @param {number } strokeWidth Stroke width to be used when drawing circle
309
316
* @param {number } value Percentage of circle (between 0 and 100)
310
317
* @param {number } limit Max percentage for circle
311
318
*
312
319
* @returns {number } Stroke length for progres circle
313
320
*/
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 ) ) ;
316
323
}
317
324
318
325
/**
0 commit comments