33 HostBinding ,
44 ChangeDetectorRef ,
55 ChangeDetectionStrategy ,
6+ OnDestroy ,
67 Input
78} from '@angular/core' ;
89
@@ -41,12 +42,19 @@ type EasingFn = (currentTime: number, startValue: number,
4142 styleUrls : [ 'progress-circle.css' ] ,
4243 changeDetection : ChangeDetectionStrategy . OnPush ,
4344} )
44- export class MdProgressCircle {
45+ export class MdProgressCircle implements OnDestroy {
4546 /** The id of the last requested animation. */
4647 private _lastAnimationId : number = 0 ;
4748
4849 /** The id of the indeterminate interval. */
4950 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+ }
5058
5159 /** The current path value, representing the progres circle. */
5260 private _currentPath : string ;
@@ -60,6 +68,11 @@ export class MdProgressCircle {
6068 this . _changeDetectorRef . markForCheck ( ) ;
6169 }
6270
71+ /** Clean up any animations that were running. */
72+ ngOnDestroy ( ) {
73+ this . _cleanupIndeterminateAnimation ( ) ;
74+ }
75+
6376 /**
6477 * Value of the progress circle.
6578 *
@@ -162,8 +175,8 @@ export class MdProgressCircle {
162175 end = - temp ;
163176 } ;
164177
165- if ( ! this . _interdeterminateInterval ) {
166- this . _interdeterminateInterval = setInterval (
178+ if ( ! this . interdeterminateInterval ) {
179+ this . interdeterminateInterval = setInterval (
167180 animate , duration + 50 , 0 , false ) ;
168181 animate ( ) ;
169182 }
@@ -174,10 +187,7 @@ export class MdProgressCircle {
174187 * Removes interval, ending the animation.
175188 */
176189 private _cleanupIndeterminateAnimation ( ) {
177- if ( this . _interdeterminateInterval ) {
178- clearInterval ( this . _interdeterminateInterval ) ;
179- this . _interdeterminateInterval = null ;
180- }
190+ this . interdeterminateInterval = null ;
181191 }
182192}
183193
@@ -219,7 +229,7 @@ function clamp(v: number) {
219229 * Returns the current timestamp either based on the performance global or a date object.
220230 */
221231function now ( ) {
222- if ( typeof performance !== 'undefined' ) {
232+ if ( typeof performance !== 'undefined' && performance . now ) {
223233 return performance . now ( ) ;
224234 }
225235 return Date . now ( ) ;
0 commit comments