@@ -92,8 +92,8 @@ function MdProgressCircularDirective($$rAF, $window, $mdProgressCircular, $mdUti
92
92
} ;
93
93
94
94
function MdProgressCircularLink ( scope , element ) {
95
- var svg = element [ 0 ] . querySelector ( 'svg' ) ;
96
- var path = angular . element ( svg . querySelector ( 'path' ) ) ;
95
+ var svg = angular . element ( element [ 0 ] . querySelector ( 'svg' ) ) ;
96
+ var path = angular . element ( element [ 0 ] . querySelector ( 'path' ) ) ;
97
97
var startIndeterminate = $mdProgressCircular . startIndeterminate ;
98
98
var endIndeterminate = $mdProgressCircular . endIndeterminate ;
99
99
var rotationIndeterminate = 0 ;
@@ -112,8 +112,11 @@ function MdProgressCircularDirective($$rAF, $window, $mdProgressCircular, $mdUti
112
112
if ( mode === MODE_INDETERMINATE ) {
113
113
startIndeterminateAnimation ( ) ;
114
114
} else {
115
+ var newValue = clamp ( newValues [ 0 ] ) ;
116
+
115
117
cleanupIndeterminateAnimation ( ) ;
116
- renderCircle ( clamp ( oldValues [ 0 ] ) , clamp ( newValues [ 0 ] ) ) ;
118
+ element . attr ( 'aria-valuenow' , newValue ) ;
119
+ renderCircle ( clamp ( oldValues [ 0 ] ) , newValue ) ;
117
120
}
118
121
}
119
122
} ) ;
@@ -123,35 +126,38 @@ function MdProgressCircularDirective($$rAF, $window, $mdProgressCircular, $mdUti
123
126
scope . $watch ( 'mdDiameter' , function ( newValue ) {
124
127
var diameter = getSize ( newValue ) ;
125
128
var strokeWidth = getStroke ( diameter ) ;
129
+ var dimensions = {
130
+ width : diameter + 'px' ,
131
+ height : diameter + 'px'
132
+ } ;
126
133
127
134
// The viewBox has to be applied via setAttribute, because it is
128
135
// case-sensitive. If jQuery is included in the page, `.attr` lowercases
129
136
// all attribute names.
130
- svg . setAttribute ( 'viewBox' , '0 0 ' + diameter + ' ' + diameter ) ;
137
+ svg [ 0 ] . setAttribute ( 'viewBox' , '0 0 ' + diameter + ' ' + diameter ) ;
138
+
139
+ // Usually viewBox sets the dimensions for the SVG, however that doesn't
140
+ // seem to be the case on IE10.
141
+ svg . css ( dimensions ) ;
142
+ element . css ( dimensions ) ;
131
143
path . css ( 'stroke-width' , strokeWidth + 'px' ) ;
132
- element . css ( {
133
- width : diameter + 'px' ,
134
- height : diameter + 'px'
135
- } ) ;
136
144
} ) ;
137
145
138
146
function renderCircle ( animateFrom , animateTo , easing , duration , rotation ) {
139
147
var id = ++ lastAnimationId ;
140
- var startTime = $window . performance . now ( ) ;
148
+ var startTime = getTimestamp ( ) ;
141
149
var changeInValue = animateTo - animateFrom ;
142
150
var diameter = getSize ( scope . mdDiameter ) ;
143
151
var pathDiameter = diameter - getStroke ( diameter ) ;
144
152
var ease = easing || $mdProgressCircular . easeFn ;
145
153
var animationDuration = duration || $mdProgressCircular . duration ;
146
154
147
- element . attr ( 'aria-valuenow' , animateTo ) ;
148
-
149
155
// No need to animate it if the values are the same
150
156
if ( animateTo === animateFrom ) {
151
157
path . attr ( 'd' , getSvgArc ( animateTo , diameter , pathDiameter , rotation ) ) ;
152
158
} else {
153
159
$$rAF ( function animation ( now ) {
154
- var currentTime = now - startTime ;
160
+ var currentTime = ( now || getTimestamp ( ) ) - startTime ;
155
161
156
162
path . attr ( 'd' , getSvgArc (
157
163
ease ( currentTime , animateFrom , changeInValue , animationDuration ) ,
@@ -187,7 +193,7 @@ function MdProgressCircularDirective($$rAF, $window, $mdProgressCircular, $mdUti
187
193
188
194
function startIndeterminateAnimation ( ) {
189
195
if ( ! interval ) {
190
- var startTime = $window . performance . now ( ) ;
196
+ var startTime = getTimestamp ( ) ;
191
197
var animationDuration = $mdProgressCircular . rotationDurationIndeterminate ;
192
198
var radius = getSize ( scope . mdDiameter ) / 2 ;
193
199
@@ -198,7 +204,8 @@ function MdProgressCircularDirective($$rAF, $window, $mdProgressCircular, $mdUti
198
204
// with CSS keyframes, however IE11 seems to have problems centering the rotation
199
205
// which causes a wobble in the indeterminate animation.
200
206
$$rAF ( function animation ( now ) {
201
- var currentTime = now - startTime ;
207
+ var timestamp = now || getTimestamp ( ) ;
208
+ var currentTime = timestamp - startTime ;
202
209
var rotation = $mdProgressCircular . easingPresets . linearEase ( currentTime , 0 , 360 , animationDuration ) ;
203
210
204
211
path . attr ( 'transform' , 'rotate(' + rotation + radius + ')' ) ;
@@ -211,11 +218,11 @@ function MdProgressCircularDirective($$rAF, $window, $mdProgressCircular, $mdUti
211
218
212
219
// Reset the animation
213
220
if ( currentTime >= animationDuration ) {
214
- startTime = now ;
221
+ startTime = timestamp ;
215
222
}
216
223
} ) ;
217
224
218
- // This shouldn't trigger a digest which is why we don't use $interval .
225
+ // Note that this interval isn't supposed to trigger a digest .
219
226
interval = $interval (
220
227
animateIndeterminate ,
221
228
$mdProgressCircular . durationIndeterminate + 50 ,
@@ -224,6 +231,7 @@ function MdProgressCircularDirective($$rAF, $window, $mdProgressCircular, $mdUti
224
231
) ;
225
232
226
233
animateIndeterminate ( ) ;
234
+ element . removeAttr ( 'aria-valuenow' ) ;
227
235
}
228
236
}
229
237
@@ -321,4 +329,12 @@ function MdProgressCircularDirective($$rAF, $window, $mdProgressCircular, $mdUti
321
329
function getStroke ( diameter ) {
322
330
return $mdProgressCircular . strokeWidth / 100 * diameter ;
323
331
}
332
+
333
+ /**
334
+ * Retrieves a timestamp for timing animations.
335
+ */
336
+ function getTimestamp ( ) {
337
+ var perf = $window . performance ;
338
+ return perf && perf . now && perf . now ( ) || + new $window . Date ( ) ;
339
+ }
324
340
}
0 commit comments