Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/lib/progress-spinner/progress-spinner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ describe('MatProgressSpinner', () => {
expect(svgElement.getAttribute('viewBox')).toBe('0 0 38 38');
});

it('should update the element size when changed dynamically', () => {
let fixture = TestBed.createComponent(BasicProgressSpinner);
let spinner = fixture.debugElement.query(By.directive(MatProgressSpinner));
spinner.componentInstance.diameter = 32;
fixture.detectChanges();
expect(spinner.nativeElement.style.width).toBe('32px');
expect(spinner.nativeElement.style.height).toBe('32px');
});
});


Expand Down
8 changes: 7 additions & 1 deletion src/lib/progress-spinner/progress-spinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
if (!this._fallbackAnimation && !MatProgressSpinner.diameters.has(this._diameter)) {
this._attachStyleNode();
}
this._updateElementSize();
}
private _diameter = BASE_SIZE;

Expand Down Expand Up @@ -165,7 +166,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements

ngOnChanges(changes: SimpleChanges) {
if (changes.strokeWidth || changes.diameter) {
this._elementSize = this._diameter + Math.max(this.strokeWidth - BASE_STROKE_WIDTH, 0);
this._updateElementSize();
}
}

Expand Down Expand Up @@ -229,6 +230,11 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
.replace(/END_VALUE/g, `${0.2 * this._strokeCircumference}`)
.replace(/DIAMETER/g, `${this.diameter}`);
}

/** Updates the spinner element size based on its diameter. */
private _updateElementSize() {
this._elementSize = this._diameter + Math.max(this.strokeWidth - BASE_STROKE_WIDTH, 0);
}
}


Expand Down