3
3
HostBinding ,
4
4
ChangeDetectorRef ,
5
5
ChangeDetectionStrategy ,
6
+ OnDestroy ,
6
7
Input
7
8
} from '@angular/core' ;
8
9
@@ -41,13 +42,23 @@ type EasingFn = (currentTime: number, startValue: number,
41
42
styleUrls : [ 'progress-circle.css' ] ,
42
43
changeDetection : ChangeDetectionStrategy . OnPush ,
43
44
} )
44
- export class MdProgressCircle {
45
+ export class MdProgressCircle implements OnDestroy {
45
46
/** The id of the last requested animation. */
46
47
private _lastAnimationId : number = 0 ;
47
48
48
49
/** The id of the indeterminate interval. */
49
50
private _interdeterminateInterval : number ;
50
51
52
+ /** @internal */
53
+ get interdeterminateInterval ( ) {
54
+ return this . _interdeterminateInterval ;
55
+ }
56
+ /** @internal */
57
+ set interdeterminateInterval ( interval : number ) {
58
+ clearInterval ( this . _interdeterminateInterval ) ;
59
+ this . _interdeterminateInterval = interval ;
60
+ }
61
+
51
62
/** The current path value, representing the progres circle. */
52
63
private _currentPath : string ;
53
64
get currentPath ( ) {
@@ -60,6 +71,11 @@ export class MdProgressCircle {
60
71
this . _changeDetectorRef . markForCheck ( ) ;
61
72
}
62
73
74
+ /** Clean up any animations that were running. */
75
+ ngOnDestroy ( ) {
76
+ this . _cleanupIndeterminateAnimation ( ) ;
77
+ }
78
+
63
79
/**
64
80
* Value of the progress circle.
65
81
*
@@ -162,8 +178,8 @@ export class MdProgressCircle {
162
178
end = - temp ;
163
179
} ;
164
180
165
- if ( ! this . _interdeterminateInterval ) {
166
- this . _interdeterminateInterval = setInterval (
181
+ if ( ! this . interdeterminateInterval ) {
182
+ this . interdeterminateInterval = setInterval (
167
183
animate , duration + 50 , 0 , false ) ;
168
184
animate ( ) ;
169
185
}
@@ -174,10 +190,7 @@ export class MdProgressCircle {
174
190
* Removes interval, ending the animation.
175
191
*/
176
192
private _cleanupIndeterminateAnimation ( ) {
177
- if ( this . _interdeterminateInterval ) {
178
- clearInterval ( this . _interdeterminateInterval ) ;
179
- this . _interdeterminateInterval = null ;
180
- }
193
+ this . interdeterminateInterval = null ;
181
194
}
182
195
}
183
196
@@ -219,7 +232,7 @@ function clamp(v: number) {
219
232
* Returns the current timestamp either based on the performance global or a date object.
220
233
*/
221
234
function now ( ) {
222
- if ( typeof performance !== 'undefined' ) {
235
+ if ( typeof performance !== 'undefined' && performance . now ) {
223
236
return performance . now ( ) ;
224
237
}
225
238
return Date . now ( ) ;
0 commit comments