44 Output ,
55 OnChanges ,
66 NgZone ,
7- ElementRef ,
87 EventEmitter ,
8+ ViewChild ,
9+ Renderer ,
910} from '@angular/core' ;
1011
1112import { RoundProgressService } from './round-progress.service' ;
@@ -25,6 +26,7 @@ import { RoundProgressEase } from './round-progress.ease';
2526 [style.stroke-width]="stroke"/>
2627
2728 <path
29+ #path
2830 fill="none"
2931 [style.stroke-width]="stroke"
3032 [style.stroke]="_service.resolveColor(color)"
@@ -33,7 +35,7 @@ import { RoundProgressEase } from './round-progress.ease';
3335 </svg>
3436 ` ,
3537 host : {
36- role : 'progressbar' ,
38+ ' role' : 'progressbar' ,
3739 '[attr.aria-valuemin]' : 'current' ,
3840 '[attr.aria-valuemax]' : 'max' ,
3941 '[style.width]' : "responsive ? '' : _diameter + 'px'" ,
@@ -61,15 +63,15 @@ import { RoundProgressEase } from './round-progress.ease';
6163 ]
6264} )
6365export class RoundProgressComponent implements OnChanges {
64- private _path : SVGPathElement ;
66+ @ ViewChild ( 'path' ) private _path ;
6567 private _lastAnimationId : number = 0 ;
6668
6769 constructor (
6870 private _service : RoundProgressService ,
6971 private _easingFunctions : RoundProgressEase ,
7072 private _defaults : RoundProgressConfig ,
7173 private _ngZone : NgZone ,
72- private _element : ElementRef
74+ private _renderer : Renderer
7375 ) { }
7476
7577 /** Animates a change in the current value. */
@@ -115,12 +117,10 @@ export class RoundProgressComponent implements OnChanges {
115117
116118 /** Sets the path dimensions. */
117119 private _setPath ( value : number ) : void {
118- if ( ! this . _path ) {
119- this . _path = this . _element . nativeElement . querySelector ( 'path' ) ;
120+ if ( this . _path ) {
121+ this . _renderer . setElementAttribute ( this . _path . nativeElement , 'd' , this . _service . getArc ( value ,
122+ this . max , this . radius - this . stroke / 2 , this . radius , this . semicircle ) ) ;
120123 }
121-
122- this . _path . setAttribute ( 'd' , this . _service . getArc ( value , this . max ,
123- this . radius - this . stroke / 2 , this . radius , this . semicircle ) ) ;
124124 }
125125
126126 /** Clamps a value between the maximum and 0. */
0 commit comments