File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -224,6 +224,14 @@ describe('MatProgressSpinner', () => {
224224 expect ( svgElement . getAttribute ( 'viewBox' ) ) . toBe ( '0 0 38 38' ) ;
225225 } ) ;
226226
227+ it ( 'should update the element size when changed dynamically' , ( ) => {
228+ let fixture = TestBed . createComponent ( BasicProgressSpinner ) ;
229+ let spinner = fixture . debugElement . query ( By . directive ( MatProgressSpinner ) ) ;
230+ spinner . componentInstance . diameter = 32 ;
231+ fixture . detectChanges ( ) ;
232+ expect ( spinner . nativeElement . style . width ) . toBe ( '32px' ) ;
233+ expect ( spinner . nativeElement . style . height ) . toBe ( '32px' ) ;
234+ } ) ;
227235} ) ;
228236
229237
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
122122 if ( ! this . _fallbackAnimation && ! MatProgressSpinner . diameters . has ( this . _diameter ) ) {
123123 this . _attachStyleNode ( ) ;
124124 }
125+ this . _updateElementSize ( ) ;
125126 }
126127 private _diameter = BASE_SIZE ;
127128
@@ -165,7 +166,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
165166
166167 ngOnChanges ( changes : SimpleChanges ) {
167168 if ( changes . strokeWidth || changes . diameter ) {
168- this . _elementSize = this . _diameter + Math . max ( this . strokeWidth - BASE_STROKE_WIDTH , 0 ) ;
169+ this . _updateElementSize ( ) ;
169170 }
170171 }
171172
@@ -229,6 +230,11 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
229230 . replace ( / E N D _ V A L U E / g, `${ 0.2 * this . _strokeCircumference } ` )
230231 . replace ( / D I A M E T E R / g, `${ this . diameter } ` ) ;
231232 }
233+
234+ /** Updates the spinner element size based on its diameter. */
235+ private _updateElementSize ( ) {
236+ this . _elementSize = this . _diameter + Math . max ( this . strokeWidth - BASE_STROKE_WIDTH , 0 ) ;
237+ }
232238}
233239
234240
You can’t perform that action at this time.
0 commit comments