From 11a4ff0a6d08e225d4b1f70d21bb0dde8011ae9a Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Wed, 12 Jun 2019 01:21:20 +0200 Subject: [PATCH] fix(card): disable all animations when using NoopAnimationsModule (#11538) * 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. * fix lint * fix api test --- src/material/card/card.scss | 2 ++ src/material/card/card.ts | 13 +++++++++++-- tools/public_api_guard/material/card.d.ts | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/material/card/card.scss b/src/material/card/card.scss index 3c7f621b457..d531f1bf93e 100644 --- a/src/material/card/card.scss +++ b/src/material/card/card.scss @@ -1,5 +1,6 @@ @import '../core/style/variables'; @import '../core/style/elevation'; +@import '../core/style/noop-animation'; @import '../../cdk/a11y/a11y'; @@ -9,6 +10,7 @@ $mat-card-header-size: 40px !default; .mat-card { @include mat-elevation-transition; + @include _noop-animation(); display: block; position: relative; padding: $mat-card-padding; diff --git a/src/material/card/card.ts b/src/material/card/card.ts index 431af65b8ac..d885264026c 100644 --- a/src/material/card/card.ts +++ b/src/material/card/card.ts @@ -12,7 +12,10 @@ import { ChangeDetectionStrategy, Directive, Input, + Optional, + Inject, } from '@angular/core'; +import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations'; /** @@ -156,9 +159,15 @@ export class MatCardAvatar {} styleUrls: ['card.css'], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, - host: {'class': 'mat-card'} + host: { + 'class': 'mat-card', + '[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"', + } }) -export class MatCard {} +export class MatCard { + // @breaking-change 9.0.0 `_animationMode` parameter to be made required. + constructor(@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string) {} +} /** diff --git a/tools/public_api_guard/material/card.d.ts b/tools/public_api_guard/material/card.d.ts index cc34096281a..16df62b8f5d 100644 --- a/tools/public_api_guard/material/card.d.ts +++ b/tools/public_api_guard/material/card.d.ts @@ -1,4 +1,6 @@ export declare class MatCard { + _animationMode?: string | undefined; + constructor(_animationMode?: string | undefined); } export declare class MatCardActions {