@@ -159,7 +159,7 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming,
159
159
diameter = getSize ( scope . mdDiameter ) ;
160
160
strokeWidth = getStroke ( diameter ) ;
161
161
path . attr ( 'd' , getSvgArc ( diameter , strokeWidth , true ) ) ;
162
- path . attr ( 'stroke-dasharray' , ( diameter - strokeWidth ) * $window . Math . PI * 0.75 ) ;
162
+ path . attr ( 'stroke-dasharray' , getDashLength ( diameter , strokeWidth , 75 ) ) ;
163
163
}
164
164
startIndeterminateAnimation ( ) ;
165
165
} else {
@@ -172,7 +172,7 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming,
172
172
diameter = getSize ( scope . mdDiameter ) ;
173
173
strokeWidth = getStroke ( diameter ) ;
174
174
path . attr ( 'd' , getSvgArc ( diameter , strokeWidth , false ) ) ;
175
- path . attr ( 'stroke-dasharray' , ( diameter - strokeWidth ) * $window . Math . PI ) ;
175
+ path . attr ( 'stroke-dasharray' , getDashLength ( diameter , strokeWidth , 100 ) ) ;
176
176
}
177
177
178
178
element . attr ( 'aria-valuenow' , newValue ) ;
@@ -216,12 +216,12 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming,
216
216
path . attr ( 'stroke-linecap' , 'square' ) ;
217
217
if ( scope . mdMode == MODE_INDETERMINATE ) {
218
218
path . attr ( 'd' , getSvgArc ( diameter , strokeWidth , true ) ) ;
219
- path . attr ( 'stroke-dasharray' , ( diameter - strokeWidth ) * $window . Math . PI * 0.75 ) ;
220
- path . attr ( 'stroke-dashoffset' , getDashLength ( diameter , strokeWidth , 1 , 75 ) ) ;
219
+ path . attr ( 'stroke-dasharray' , getDashLength ( diameter , strokeWidth , 75 ) ) ;
220
+ path . attr ( 'stroke-dashoffset' , getDashOffset ( diameter , strokeWidth , 1 , 75 ) ) ;
221
221
} else {
222
222
path . attr ( 'd' , getSvgArc ( diameter , strokeWidth , false ) ) ;
223
- path . attr ( 'stroke-dasharray' , ( diameter - strokeWidth ) * $window . Math . PI ) ;
224
- path . attr ( 'stroke-dashoffset' , getDashLength ( diameter , strokeWidth , 0 , 100 ) ) ;
223
+ path . attr ( 'stroke-dasharray' , getDashLength ( diameter , strokeWidth , 100 ) ) ;
224
+ path . attr ( 'stroke-dashoffset' , getDashOffset ( diameter , strokeWidth , 0 , 100 ) ) ;
225
225
renderCircle ( value , value ) ;
226
226
}
227
227
@@ -255,7 +255,7 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming,
255
255
}
256
256
257
257
function renderFrame ( value ) {
258
- path . attr ( 'stroke-dashoffset' , getDashLength ( diameter , strokeWidth , value , dashLimit ) ) ;
258
+ path . attr ( 'stroke-dashoffset' , getDashOffset ( diameter , strokeWidth , value , dashLimit ) ) ;
259
259
path . attr ( 'transform' , 'rotate(' + ( rotation ) + ' ' + diameter / 2 + ' ' + diameter / 2 + ')' ) ;
260
260
}
261
261
}
@@ -330,12 +330,12 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming,
330
330
* @param {number } diameter Diameter of the container.
331
331
* @param {number } strokeWidth Stroke width to be used when drawing circle
332
332
* @param {number } value Percentage of circle (between 0 and 100)
333
- * @param {number } limit Max percentage for circle
333
+ * @param {number } maxArcLength Maximum length of arc as a percentage of circle (between 0 and 100)
334
334
*
335
- * @returns {number } Stroke length for progres circle
335
+ * @returns {number } Stroke length for progress circle
336
336
*/
337
- function getDashLength ( diameter , strokeWidth , value , limit ) {
338
- return ( diameter - strokeWidth ) * $window . Math . PI * ( ( 3 * ( limit || 100 ) / 100 ) - ( value / 100 ) ) ;
337
+ function getDashOffset ( diameter , strokeWidth , value , maxArcLength ) {
338
+ return getSpinnerCircumference ( diameter , strokeWidth ) * ( ( maxArcLength - value ) / 100 ) ;
339
339
}
340
340
341
341
/**
@@ -373,4 +373,29 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming,
373
373
return $mdProgressCircular . strokeWidth / 100 * diameter ;
374
374
}
375
375
376
+ /**
377
+ * Return length of the dash
378
+ *
379
+ * @param {number } diameter Diameter of the container.
380
+ * @param {number } strokeWidth Stroke width to be used when drawing circle
381
+ * @param {number } value Percentage of circle (between 0 and 100)
382
+ *
383
+ * @returns {number } Length of the dash
384
+ */
385
+ function getDashLength ( diameter , strokeWidth , value ) {
386
+ return getSpinnerCircumference ( diameter , strokeWidth ) * ( value / 100 ) ;
387
+ }
388
+
389
+ /**
390
+ * Return circumference of the spinner
391
+ *
392
+ * @param {number } diameter Diameter of the container.
393
+ * @param {number } strokeWidth Stroke width to be used when drawing circle
394
+ *
395
+ * @returns {number } Circumference of the spinner
396
+ */
397
+ function getSpinnerCircumference ( diameter , strokeWidth ) {
398
+ return ( ( diameter - strokeWidth ) * $window . Math . PI ) ;
399
+ }
400
+
376
401
}
0 commit comments