Skip to content

Commit 3e22641

Browse files
crisbetojelbourn
authored andcommitted
fix(expansion): disable all animations when using NoopAnimationsModule (#12855)
Disables all of the expansion panel animations if it's inside a module with the NoopAnimationsModule. Also removes the mat-elevation-transition from the expansion panel, because it hasn't been doing anything for a while since it gets overwritten by the margin transition below. Relates to #10590.
1 parent ae3ce4a commit 3e22641

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/lib/expansion/expansion-panel.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
@include cdk-high-contrast {
3333
outline: solid 1px;
3434
}
35+
36+
&.ng-animate-disabled,
37+
.ng-animate-disabled &,
38+
&._mat-animation-noopable {
39+
transition: none;
40+
}
3541
}
3642

3743
.mat-expansion-panel-content {

src/lib/expansion/expansion-panel.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
ViewChild,
3434
} from '@angular/core';
3535
import {DOCUMENT} from '@angular/common';
36+
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
3637
import {Subject} from 'rxjs';
3738
import {filter, startWith, take} from 'rxjs/operators';
3839
import {matExpansionAnimations} from './expansion-animations';
@@ -73,6 +74,7 @@ let uniqueId = 0;
7374
host: {
7475
'class': 'mat-expansion-panel',
7576
'[class.mat-expanded]': 'expanded',
77+
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
7678
'[class.mat-expansion-panel-spacing]': '_hasSpacing()',
7779
}
7880
})
@@ -121,7 +123,9 @@ export class MatExpansionPanel extends CdkAccordionItem implements AfterContentI
121123
_changeDetectorRef: ChangeDetectorRef,
122124
_uniqueSelectionDispatcher: UniqueSelectionDispatcher,
123125
private _viewContainerRef: ViewContainerRef,
124-
@Inject(DOCUMENT) _document?: any) {
126+
// @breaking-change 8.0.0 _document and _animationMode to be made required
127+
@Inject(DOCUMENT) _document?: any,
128+
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string) {
125129
super(accordion, _changeDetectorRef, _uniqueSelectionDispatcher);
126130
this.accordion = accordion;
127131
this._document = _document;

0 commit comments

Comments
 (0)