Skip to content

Commit 77e602f

Browse files
crisbetoandrewseguin
authored andcommitted
fix(progress-spinner): animation not working when default size is set via token (#11688)
Fixes the progress spinner's animation not working when a different diameter is passed in through the `MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS` token. The issue comes from the fact that setting the defaults wasn't going through the appropriate setters, which meant that we weren't generating the appropriate `style` tag for that size. Fixes #11687.
1 parent 66f7efb commit 77e602f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/lib/progress-spinner/progress-spinner.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const INDETERMINATE_ANIMATION_TEMPLATE = `
119119
export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements CanColor {
120120

121121
private _value = 0;
122-
private _strokeWidth = this._defaults ? this._defaults.strokeWidth : undefined;
122+
private _strokeWidth: number;
123123
private _fallbackAnimation = false;
124124

125125
/** Tracks diameters of existing instances to de-dupe generated styles (default d = 100) */
@@ -141,8 +141,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
141141
this._attachStyleNode();
142142
}
143143
}
144-
private _diameter = this._defaults && this._defaults.diameter ?
145-
this._defaults.diameter : BASE_SIZE;
144+
private _diameter = BASE_SIZE;
146145

147146
/** Stroke width of the progress spinner. */
148147
@Input()
@@ -168,14 +167,24 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
168167
constructor(public _elementRef: ElementRef,
169168
platform: Platform,
170169
@Optional() @Inject(DOCUMENT) private _document: any,
171-
// @deletion-target 7.0.0 _animationMode and _defaults parameters to be made required.
170+
// @deletion-target 7.0.0 _animationMode and defaults parameters to be made required.
172171
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string,
173172
@Inject(MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS)
174-
private _defaults?: MatProgressSpinnerDefaultOptions) {
173+
defaults?: MatProgressSpinnerDefaultOptions) {
175174

176175
super(_elementRef);
177176
this._fallbackAnimation = platform.EDGE || platform.TRIDENT;
178177

178+
if (defaults) {
179+
if (defaults.diameter) {
180+
this.diameter = defaults.diameter;
181+
}
182+
183+
if (defaults.strokeWidth) {
184+
this.strokeWidth = defaults.strokeWidth;
185+
}
186+
}
187+
179188
// On IE and Edge, we can't animate the `stroke-dashoffset`
180189
// reliably so we fall back to a non-spec animation.
181190
const animationClass =

0 commit comments

Comments
 (0)