Skip to content

Commit e9eabcf

Browse files
committed
fix(card): disable all animations when using NoopAnimationsModule
Fixes the card `box-shadow` transition not being disabled when it's inside something with the `NoopAnimationsModule`. Relates to #10590.
1 parent 84634cc commit e9eabcf

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/lib/card/card.scss

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

56

@@ -11,6 +12,7 @@ $mat-card-header-size: 40px !default;
1112
.mat-card {
1213
@include mat-elevation-transition;
1314
@include mat-overridable-elevation(2);
15+
@include _noop-animation();
1416
display: block;
1517
position: relative;
1618
padding: $mat-card-default-padding;

src/lib/card/card.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import {
1212
ChangeDetectionStrategy,
1313
Directive,
1414
Input,
15+
Optional,
16+
Inject,
1517
} from '@angular/core';
18+
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
1619

1720

1821
/**
@@ -156,9 +159,15 @@ export class MatCardAvatar {}
156159
styleUrls: ['card.css'],
157160
encapsulation: ViewEncapsulation.None,
158161
changeDetection: ChangeDetectionStrategy.OnPush,
159-
host: {'class': 'mat-card'}
162+
host: {
163+
'class': 'mat-card',
164+
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
165+
}
160166
})
161-
export class MatCard {}
167+
export class MatCard {
168+
// @deletion-target 7.0.0 `_animationMode` parameter to be made required.
169+
constructor(@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string) {}
170+
}
162171

163172

164173
/**

0 commit comments

Comments
 (0)