|
6 | 6 | * found in the LICENSE file at https://angular.io/license |
7 | 7 | */ |
8 | 8 |
|
| 9 | +import {CanColor, mixinColor} from '@angular/material/core'; |
9 | 10 | import { |
10 | | - Component, |
11 | 11 | ChangeDetectionStrategy, |
12 | | - Input, |
| 12 | + Component, |
13 | 13 | ElementRef, |
14 | | - SimpleChanges, |
| 14 | + Inject, |
| 15 | + Input, |
15 | 16 | OnChanges, |
16 | | - ViewEncapsulation, |
17 | 17 | Optional, |
18 | | - Inject, |
| 18 | + SimpleChanges, |
| 19 | + ViewEncapsulation, |
19 | 20 | } from '@angular/core'; |
20 | | -import {CanColor, mixinColor} from '@angular/material/core'; |
21 | | -import {Platform} from '@angular/cdk/platform'; |
| 21 | + |
22 | 22 | import {DOCUMENT} from '@angular/common'; |
| 23 | +import {Platform} from '@angular/cdk/platform'; |
23 | 24 | import {coerceNumberProperty} from '@angular/cdk/coercion'; |
24 | 25 |
|
25 | 26 | /** Possible mode for a progress spinner. */ |
@@ -122,6 +123,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements |
122 | 123 | if (!this._fallbackAnimation && !MatProgressSpinner.diameters.has(this._diameter)) { |
123 | 124 | this._attachStyleNode(); |
124 | 125 | } |
| 126 | + this._updateSpinnerDimension(); |
125 | 127 | } |
126 | 128 | private _diameter = BASE_SIZE; |
127 | 129 |
|
@@ -165,7 +167,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements |
165 | 167 |
|
166 | 168 | ngOnChanges(changes: SimpleChanges) { |
167 | 169 | if (changes.strokeWidth || changes.diameter) { |
168 | | - this._elementSize = this._diameter + Math.max(this.strokeWidth - BASE_STROKE_WIDTH, 0); |
| 170 | + this._updateSpinnerDimension(); |
169 | 171 | } |
170 | 172 | } |
171 | 173 |
|
@@ -229,6 +231,11 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements |
229 | 231 | .replace(/END_VALUE/g, `${0.2 * this._strokeCircumference}`) |
230 | 232 | .replace(/DIAMETER/g, `${this.diameter}`); |
231 | 233 | } |
| 234 | + |
| 235 | + /** Updates the spinner element size based on its diameter. */ |
| 236 | + private _updateElementSize() { |
| 237 | + this._elementSize = this._diameter + Math.max(this.strokeWidth - BASE_STROKE_WIDTH, 0); |
| 238 | + } |
232 | 239 | } |
233 | 240 |
|
234 | 241 |
|
|
0 commit comments