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 @@ -120,6 +120,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
120120 if ( ! this . _fallbackAnimation && ! MatProgressSpinner . diameters . has ( this . _diameter ) ) {
121121 this . _attachStyleNode ( ) ;
122122 }
123+ this . _updateElementSize ( ) ;
123124 }
124125 private _diameter = BASE_SIZE ;
125126
@@ -162,7 +163,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
162163
163164 ngOnChanges ( changes : SimpleChanges ) {
164165 if ( changes . strokeWidth || changes . diameter ) {
165- this . _elementSize = this . _diameter + Math . max ( this . strokeWidth - BASE_STROKE_WIDTH , 0 ) ;
166+ this . _updateElementSize ( ) ;
166167 }
167168 }
168169
@@ -226,6 +227,11 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
226227 . replace ( / E N D _ V A L U E / g, `${ 0.2 * this . _strokeCircumference } ` )
227228 . replace ( / D I A M E T E R / g, `${ this . diameter } ` ) ;
228229 }
230+
231+ /** Updates the spinner element size based on its diameter. */
232+ private _updateElementSize ( ) {
233+ this . _elementSize = this . _diameter + Math . max ( this . strokeWidth - BASE_STROKE_WIDTH , 0 ) ;
234+ }
229235}
230236
231237
You can’t perform that action at this time.
0 commit comments