Skip to content

chore(dialog): update dialog animations for 2018 material spec update #13059

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 1 commit into from
Sep 11, 2018
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
29 changes: 18 additions & 11 deletions src/lib/dialog/dialog-animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,26 @@ import {
AnimationTriggerMetadata,
} from '@angular/animations';

const animationBody = [
// Note: The `enter` animation transitions to `transform: none`, because for some reason
// specifying the transform explicitly, causes IE both to blur the dialog content and
// decimate the animation performance. Leaving it as `none` solves both issues.
state('void, exit', style({opacity: 0, transform: 'scale(0.7)'})),
state('enter', style({transform: 'none'})),
transition('* => enter', animate('150ms cubic-bezier(0, 0, 0.2, 1)',
style({transform: 'none', opacity: 1}))),
transition('* => void, * => exit',
animate('75ms cubic-bezier(0.4, 0.0, 0.2, 1)', style({opacity: 0}))),
];

/** Animations used by MatDialog. */
export const matDialogAnimations: {
readonly dialogContainer: AnimationTriggerMetadata;
readonly slideDialog: AnimationTriggerMetadata;
} = {
/** Animation that slides the dialog in and out of view and fades the opacity. */
slideDialog: trigger('slideDialog', [
// Note: The `enter` animation doesn't transition to something like `translate3d(0, 0, 0)
// scale(1)`, because for some reason specifying the transform explicitly, causes IE both
// to blur the dialog content and decimate the animation performance. Leaving it as `none`
// solves both issues.
state('enter', style({ transform: 'none', opacity: 1 })),
state('void', style({ transform: 'translate3d(0, 25%, 0) scale(0.9)', opacity: 0 })),
state('exit', style({ transform: 'translate3d(0, 25%, 0)', opacity: 0 })),
transition('* => *', animate('400ms cubic-bezier(0.25, 0.8, 0.25, 1)')),
])
/** Animation that is applied on the dialog container by defalt. */
dialogContainer: trigger('dialogContainer', animationBody),

/** @deprecated @breaking-change 8.0.0 Use `matDialogAnimations.dialogContainer` instead. */
slideDialog: trigger('slideDialog', animationBody)
};
10 changes: 5 additions & 5 deletions src/lib/dialog/dialog-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function throwMatDialogContentAlreadyAttachedError() {
// Using OnPush for dialogs caused some G3 sync issues. Disabled until we can track them down.
// tslint:disable-next-line:validate-decorators
changeDetection: ChangeDetectionStrategy.Default,
animations: [matDialogAnimations.slideDialog],
animations: [matDialogAnimations.dialogContainer],
host: {
'class': 'mat-dialog-container',
'tabindex': '-1',
Expand All @@ -65,9 +65,9 @@ export function throwMatDialogContentAlreadyAttachedError() {
'[attr.aria-labelledby]': '_config.ariaLabel ? null : _ariaLabelledBy',
'[attr.aria-label]': '_config.ariaLabel',
'[attr.aria-describedby]': '_config.ariaDescribedBy || null',
'[@slideDialog]': '_state',
'(@slideDialog.start)': '_onAnimationStart($event)',
'(@slideDialog.done)': '_onAnimationDone($event)',
'[@dialogContainer]': '_state',
'(@dialogContainer.start)': '_onAnimationStart($event)',
'(@dialogContainer.done)': '_onAnimationDone($event)',
},
})
export class MatDialogContainer extends BasePortalOutlet {
Expand All @@ -93,7 +93,7 @@ export class MatDialogContainer extends BasePortalOutlet {
_id: string;

constructor(
private _elementRef: ElementRef<HTMLElement>,
private _elementRef: ElementRef,
private _focusTrapFactory: FocusTrapFactory,
private _changeDetectorRef: ChangeDetectorRef,
@Optional() @Inject(DOCUMENT) private _document: any,
Expand Down