Skip to content

fix(card): disable all animations when using NoopAnimationsModule #11538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/material/card/card.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import '../core/style/variables';
@import '../core/style/elevation';
@import '../core/style/noop-animation';
@import '../../cdk/a11y/a11y';


Expand All @@ -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;
Expand Down
13 changes: 11 additions & 2 deletions src/material/card/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import {
ChangeDetectionStrategy,
Directive,
Input,
Optional,
Inject,
} from '@angular/core';
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';


/**
Expand Down Expand Up @@ -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) {}
}


/**
Expand Down
2 changes: 2 additions & 0 deletions tools/public_api_guard/material/card.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export declare class MatCard {
_animationMode?: string | undefined;
constructor(_animationMode?: string | undefined);
}

export declare class MatCardActions {
Expand Down