Skip to content

Commit 1908b3e

Browse files
chore(dialog): update dialog animations for 2018 material spec update (#13059)
1 parent 041a41d commit 1908b3e

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

src/lib/dialog/dialog-animations.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,26 @@ import {
1414
AnimationTriggerMetadata,
1515
} from '@angular/animations';
1616

17+
const animationBody = [
18+
// Note: The `enter` animation transitions to `transform: none`, because for some reason
19+
// specifying the transform explicitly, causes IE both to blur the dialog content and
20+
// decimate the animation performance. Leaving it as `none` solves both issues.
21+
state('void, exit', style({opacity: 0, transform: 'scale(0.7)'})),
22+
state('enter', style({transform: 'none'})),
23+
transition('* => enter', animate('150ms cubic-bezier(0, 0, 0.2, 1)',
24+
style({transform: 'none', opacity: 1}))),
25+
transition('* => void, * => exit',
26+
animate('75ms cubic-bezier(0.4, 0.0, 0.2, 1)', style({opacity: 0}))),
27+
];
28+
1729
/** Animations used by MatDialog. */
1830
export const matDialogAnimations: {
31+
readonly dialogContainer: AnimationTriggerMetadata;
1932
readonly slideDialog: AnimationTriggerMetadata;
2033
} = {
21-
/** Animation that slides the dialog in and out of view and fades the opacity. */
22-
slideDialog: trigger('slideDialog', [
23-
// Note: The `enter` animation doesn't transition to something like `translate3d(0, 0, 0)
24-
// scale(1)`, because for some reason specifying the transform explicitly, causes IE both
25-
// to blur the dialog content and decimate the animation performance. Leaving it as `none`
26-
// solves both issues.
27-
state('enter', style({ transform: 'none', opacity: 1 })),
28-
state('void', style({ transform: 'translate3d(0, 25%, 0) scale(0.9)', opacity: 0 })),
29-
state('exit', style({ transform: 'translate3d(0, 25%, 0)', opacity: 0 })),
30-
transition('* => *', animate('400ms cubic-bezier(0.25, 0.8, 0.25, 1)')),
31-
])
34+
/** Animation that is applied on the dialog container by defalt. */
35+
dialogContainer: trigger('dialogContainer', animationBody),
36+
37+
/** @deprecated @breaking-change 8.0.0 Use `matDialogAnimations.dialogContainer` instead. */
38+
slideDialog: trigger('slideDialog', animationBody)
3239
};

src/lib/dialog/dialog-container.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function throwMatDialogContentAlreadyAttachedError() {
5555
// Using OnPush for dialogs caused some G3 sync issues. Disabled until we can track them down.
5656
// tslint:disable-next-line:validate-decorators
5757
changeDetection: ChangeDetectionStrategy.Default,
58-
animations: [matDialogAnimations.slideDialog],
58+
animations: [matDialogAnimations.dialogContainer],
5959
host: {
6060
'class': 'mat-dialog-container',
6161
'tabindex': '-1',
@@ -65,9 +65,9 @@ export function throwMatDialogContentAlreadyAttachedError() {
6565
'[attr.aria-labelledby]': '_config.ariaLabel ? null : _ariaLabelledBy',
6666
'[attr.aria-label]': '_config.ariaLabel',
6767
'[attr.aria-describedby]': '_config.ariaDescribedBy || null',
68-
'[@slideDialog]': '_state',
69-
'(@slideDialog.start)': '_onAnimationStart($event)',
70-
'(@slideDialog.done)': '_onAnimationDone($event)',
68+
'[@dialogContainer]': '_state',
69+
'(@dialogContainer.start)': '_onAnimationStart($event)',
70+
'(@dialogContainer.done)': '_onAnimationDone($event)',
7171
},
7272
})
7373
export class MatDialogContainer extends BasePortalOutlet {
@@ -93,7 +93,7 @@ export class MatDialogContainer extends BasePortalOutlet {
9393
_id: string;
9494

9595
constructor(
96-
private _elementRef: ElementRef<HTMLElement>,
96+
private _elementRef: ElementRef,
9797
private _focusTrapFactory: FocusTrapFactory,
9898
private _changeDetectorRef: ChangeDetectorRef,
9999
@Optional() @Inject(DOCUMENT) private _document: any,

0 commit comments

Comments
 (0)