3
3
HostBinding ,
4
4
ChangeDetectorRef ,
5
5
ChangeDetectionStrategy ,
6
+ OnDestroy ,
6
7
Input
7
8
} from '@angular/core' ;
8
9
@@ -41,12 +42,19 @@ 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 ;
51
+ get interdeterminateInterval ( ) {
52
+ return this . _interdeterminateInterval ;
53
+ }
54
+ set interdeterminateInterval ( interval : number ) {
55
+ clearInterval ( this . _interdeterminateInterval ) ;
56
+ this . _interdeterminateInterval = interval ;
57
+ }
50
58
51
59
/** The current path value, representing the progres circle. */
52
60
private _currentPath : string ;
@@ -60,6 +68,11 @@ export class MdProgressCircle {
60
68
this . _changeDetectorRef . markForCheck ( ) ;
61
69
}
62
70
71
+ /** Clean up any animations that were running. */
72
+ ngOnDestroy ( ) {
73
+ this . _cleanupIndeterminateAnimation ( ) ;
74
+ }
75
+
63
76
/**
64
77
* Value of the progress circle.
65
78
*
@@ -160,10 +173,11 @@ export class MdProgressCircle {
160
173
let temp = start ;
161
174
start = - end ;
162
175
end = - temp ;
176
+ console . log ( end ) ;
163
177
} ;
164
178
165
- if ( ! this . _interdeterminateInterval ) {
166
- this . _interdeterminateInterval = setInterval (
179
+ if ( ! this . interdeterminateInterval ) {
180
+ this . interdeterminateInterval = setInterval (
167
181
animate , duration + 50 , 0 , false ) ;
168
182
animate ( ) ;
169
183
}
@@ -174,10 +188,7 @@ export class MdProgressCircle {
174
188
* Removes interval, ending the animation.
175
189
*/
176
190
private _cleanupIndeterminateAnimation ( ) {
177
- if ( this . _interdeterminateInterval ) {
178
- clearInterval ( this . _interdeterminateInterval ) ;
179
- this . _interdeterminateInterval = null ;
180
- }
191
+ this . interdeterminateInterval = null ;
181
192
}
182
193
}
183
194
@@ -219,7 +230,7 @@ function clamp(v: number) {
219
230
* Returns the current timestamp either based on the performance global or a date object.
220
231
*/
221
232
function now ( ) {
222
- if ( typeof performance !== 'undefined' ) {
233
+ if ( typeof performance !== 'undefined' && performance . now ) {
223
234
return performance . now ( ) ;
224
235
}
225
236
return Date . now ( ) ;
0 commit comments