Skip to content

fix(progress-spinner): Create internal default to force animations to always be on #11462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2018
Merged
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
19 changes: 14 additions & 5 deletions src/lib/progress-spinner/progress-spinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export interface MatProgressSpinnerDefaultOptions {
diameter?: number;
/** Width of the spinner's stroke. */
strokeWidth?: number;
/**
* Whether the animations should be force to be enabled, ignoring if the current environment is
* using NoopAnimationsModule.
*/
_forceAnimations?: boolean;
}

/** Injection token to be used to override the default options for `mat-progress-spinner`. */
Expand Down Expand Up @@ -102,7 +107,7 @@ const INDETERMINATE_ANIMATION_TEMPLATE = `
host: {
'role': 'progressbar',
'class': 'mat-progress-spinner',
'[class._mat-animation-noopable]': `_animationMode === 'NoopAnimations'`,
'[class._mat-animation-noopable]': `_noopAnimations`,
'[style.width.px]': 'diameter',
'[style.height.px]': 'diameter',
'[attr.aria-valuemin]': 'mode === "determinate" ? 0 : null',
Expand Down Expand Up @@ -131,6 +136,10 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
*/
private static styleTag: HTMLStyleElement|null = null;

/** Whether the _mat-animation-noopable class should be applied, disabling animations. */
_noopAnimations: boolean = this.animationMode === 'NoopAnimations' && (
!!this.defaults && !this.defaults._forceAnimations);

/** The diameter of the progress spinner (will set width and height of svg). */
@Input()
get diameter(): number { return this._diameter; }
Expand Down Expand Up @@ -167,10 +176,10 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
constructor(public _elementRef: ElementRef,
platform: Platform,
@Optional() @Inject(DOCUMENT) private _document: any,
// @deletion-target 7.0.0 _animationMode and defaults parameters to be made required.
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string,
// @deletion-target 7.0.0 animationMode and defaults parameters to be made required.
@Optional() @Inject(ANIMATION_MODULE_TYPE) private animationMode?: string,
@Inject(MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS)
defaults?: MatProgressSpinnerDefaultOptions) {
private defaults?: MatProgressSpinnerDefaultOptions) {

super(_elementRef);
this._fallbackAnimation = platform.EDGE || platform.TRIDENT;
Expand Down Expand Up @@ -269,7 +278,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
'role': 'progressbar',
'mode': 'indeterminate',
'class': 'mat-spinner mat-progress-spinner',
'[class._mat-animation-noopable]': `_animationMode === 'NoopAnimations'`,
'[class._mat-animation-noopable]': `_noopAnimations`,
'[style.width.px]': 'diameter',
'[style.height.px]': 'diameter',
},
Expand Down