Skip to content

Commit 97aac4e

Browse files
andrewseguinannieyw
authored andcommitted
fix(material-experimental/mdc-snack-bar): disable animations in noop (#21377)
(cherry picked from commit bcbdb74)
1 parent 1dab32c commit 97aac4e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/material-experimental/mdc-snack-bar/snack-bar-container.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
@include cdk-high-contrast(active, off) {
1414
border: solid 1px;
1515
}
16+
17+
&._mat-animation-noopable .mdc-snackbar__surface {
18+
transition: none;
19+
}
1620
}
1721

1822
// These elements need to have full width using flex layout.

src/material-experimental/mdc-snack-bar/snack-bar-container.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ import {
2020
ComponentRef,
2121
ElementRef,
2222
EmbeddedViewRef,
23+
Inject,
2324
NgZone,
2425
OnDestroy,
26+
Optional,
2527
ViewChild,
2628
ViewEncapsulation
2729
} from '@angular/core';
2830
import {MatSnackBarConfig, _SnackBarContainer} from '@angular/material/snack-bar';
31+
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
2932
import {MDCSnackbarAdapter, MDCSnackbarFoundation} from '@material/snackbar';
3033
import {Platform} from '@angular/cdk/platform';
3134
import {Observable, Subject} from 'rxjs';
@@ -57,6 +60,7 @@ const MDC_SNACKBAR_LABEL_CLASS = 'mdc-snackbar__label';
5760
// been dismissed and will soon be removed from the DOM. This is used by the snackbar
5861
// test harness.
5962
'[attr.mat-exit]': `_exiting ? '' : null`,
63+
'[class._mat-animation-noopable]': `_animationMode === 'NoopAnimations'`,
6064
}
6165
})
6266
export class MatSnackBarContainer extends BasePortalOutlet
@@ -114,7 +118,8 @@ export class MatSnackBarContainer extends BasePortalOutlet
114118
private _elementRef: ElementRef<HTMLElement>,
115119
public snackBarConfig: MatSnackBarConfig,
116120
private _platform: Platform,
117-
private _ngZone: NgZone) {
121+
private _ngZone: NgZone,
122+
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string) {
118123
super();
119124

120125
// Use aria-live rather than a live role like 'alert' or 'status'

0 commit comments

Comments
 (0)