Skip to content

Commit 235add9

Browse files
crisbetojelbourn
authored andcommittedNov 3, 2018
fix(dialog,bottom-sheet): enter animation blocking child animations (#13888)
Currently the enter animations for the Material dialog, CDK dialog and bottom sheet are set up to be blocking, which means that any components with an initial animation inside them will be blocked until they're done. These changes allow for the child animations to run in parallel. Fixes #13870.
1 parent 28e3d36 commit 235add9

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed
 

‎src/cdk-experimental/dialog/dialog-container.ts

+18-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {animate, AnimationEvent, state, style, transition, trigger} from '@angular/animations';
9+
import {
10+
animate,
11+
AnimationEvent,
12+
state,
13+
style,
14+
transition,
15+
trigger,
16+
group,
17+
query,
18+
animateChild,
19+
} from '@angular/animations';
1020
import {FocusTrapFactory} from '@angular/cdk/a11y';
1121
import {
1222
BasePortalOutlet,
@@ -54,9 +64,13 @@ export function throwDialogContentAlreadyAttachedError() {
5464
changeDetection: ChangeDetectionStrategy.Default,
5565
animations: [
5666
trigger('dialog', [
57-
state('enter', style({ opacity: 1 })),
58-
state('exit, void', style({ opacity: 0 })),
59-
transition('* => *', animate(225)),
67+
state('enter', style({opacity: 1})),
68+
state('exit, void', style({opacity: 0})),
69+
transition('* => *', group([
70+
// `animateChild` allows for child component to animate at the same time. See #13870.
71+
query('@*', animateChild(), {optional: true}),
72+
animate(225),
73+
])),
6074
])
6175
],
6276
host: {

‎src/lib/bottom-sheet/bottom-sheet-animations.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import {
1212
transition,
1313
trigger,
1414
AnimationTriggerMetadata,
15+
group,
16+
query,
17+
animateChild,
1518
} from '@angular/animations';
1619
import {AnimationCurves, AnimationDurations} from '@angular/material/core';
1720

@@ -25,7 +28,10 @@ export const matBottomSheetAnimations: {
2528
state('visible', style({transform: 'translateY(0%)'})),
2629
transition('visible => void, visible => hidden',
2730
animate(`${AnimationDurations.COMPLEX} ${AnimationCurves.ACCELERATION_CURVE}`)),
28-
transition('void => visible',
29-
animate(`${AnimationDurations.EXITING} ${AnimationCurves.DECELERATION_CURVE}`)),
31+
transition('void => visible', group([
32+
// `animateChild` allows for child component to animate at the same time. See #13870.
33+
query('@*', animateChild(), {optional: true}),
34+
animate(`${AnimationDurations.EXITING} ${AnimationCurves.DECELERATION_CURVE}`),
35+
]))
3036
])
3137
};

‎src/lib/dialog/dialog-animations.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import {
1212
transition,
1313
trigger,
1414
AnimationTriggerMetadata,
15+
query,
16+
animateChild,
17+
group,
1518
} from '@angular/animations';
1619

1720
const animationBody = [
@@ -20,10 +23,13 @@ const animationBody = [
2023
// decimate the animation performance. Leaving it as `none` solves both issues.
2124
state('void, exit', style({opacity: 0, transform: 'scale(0.7)'})),
2225
state('enter', style({transform: 'none'})),
23-
transition('* => enter', animate('150ms cubic-bezier(0, 0, 0.2, 1)',
24-
style({transform: 'none', opacity: 1}))),
26+
transition('* => enter', group([
27+
// `animateChild` allows for child component to animate at the same time. See #13870.
28+
query('@*', animateChild(), {optional: true}),
29+
animate('150ms cubic-bezier(0, 0, 0.2, 1)', style({transform: 'none', opacity: 1})),
30+
])),
2531
transition('* => void, * => exit',
26-
animate('75ms cubic-bezier(0.4, 0.0, 0.2, 1)', style({opacity: 0}))),
32+
animate('75ms cubic-bezier(0.4, 0.0, 0.2, 1)', style({opacity: 0}))),
2733
];
2834

2935
/**

0 commit comments

Comments
 (0)
Please sign in to comment.