Skip to content

Commit 0620d24

Browse files
committed
fix(expansion): disable all animations when using NoopAnimationsModule
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 4ee0b87 commit 0620d24

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/lib/expansion/expansion-panel.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
@import '../core/style/variables';
22
@import '../core/style/elevation';
3+
@import '../core/style/noop-animation';
34
@import '../../cdk/a11y/a11y';
45

56
.mat-expansion-panel {
6-
@include mat-elevation-transition;
77
@include mat-overridable-elevation(2);
8+
@include _noop-animation();
89
box-sizing: content-box;
910
display: block;
1011
margin: 0;

src/lib/expansion/expansion-panel.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ import {
2626
SkipSelf,
2727
ViewContainerRef,
2828
ViewEncapsulation,
29+
Inject,
2930
} from '@angular/core';
3031
import {Subject} from 'rxjs';
3132
import {filter, startWith, take} from 'rxjs/operators';
3233
import {MatAccordion} from './accordion';
3334
import {matExpansionAnimations} from './expansion-animations';
3435
import {MatExpansionPanelContent} from './expansion-panel-content';
36+
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
3537

3638

3739
/** MatExpansionPanel's states. */
@@ -66,6 +68,7 @@ let uniqueId = 0;
6668
'class': 'mat-expansion-panel',
6769
'[class.mat-expanded]': 'expanded',
6870
'[class.mat-expansion-panel-spacing]': '_hasSpacing()',
71+
'[class._mat-animation-noopable]': `_animationMode === 'NoopAnimations'`,
6972
}
7073
})
7174
export class MatExpansionPanel extends CdkAccordionItem
@@ -96,7 +99,8 @@ export class MatExpansionPanel extends CdkAccordionItem
9699
constructor(@Optional() @SkipSelf() accordion: MatAccordion,
97100
_changeDetectorRef: ChangeDetectorRef,
98101
_uniqueSelectionDispatcher: UniqueSelectionDispatcher,
99-
private _viewContainerRef: ViewContainerRef) {
102+
private _viewContainerRef: ViewContainerRef,
103+
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string) {
100104
super(accordion, _changeDetectorRef, _uniqueSelectionDispatcher);
101105
this.accordion = accordion;
102106
}

0 commit comments

Comments
 (0)