Skip to content

Commit

Permalink
fix(multiple): don't block child component animations on open (#24529)
Browse files Browse the repository at this point in the history
Reworks several components that usually contain projected content not to block animations within that content. This prevents things like expansion panels from appearing as open.

These changes are identical to #13888 which had to be reverted in the past.

Fixes #13870.
  • Loading branch information
crisbeto authored Mar 6, 2022
1 parent 2aaa9d4 commit 5edcc68
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
28 changes: 25 additions & 3 deletions src/cdk-experimental/dialog/dialog-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@
* found in the LICENSE file at https://angular.io/license
*/

import {animate, AnimationEvent, state, style, transition, trigger} from '@angular/animations';
import {
animate,
animateChild,
AnimationEvent,
group,
query,
state,
style,
transition,
trigger,
} from '@angular/animations';
import {FocusTrapFactory, InteractivityChecker} from '@angular/cdk/a11y';
import {_getFocusedElementPierceShadowDom} from '@angular/cdk/platform';
import {
Expand Down Expand Up @@ -55,8 +65,20 @@ export function throwDialogContentAlreadyAttachedError() {
trigger('dialog', [
state('enter', style({opacity: 1})),
state('exit, void', style({opacity: 0})),
transition('* => enter', animate('{{enterAnimationDuration}}')),
transition('* => exit, * => void', animate('{{exitAnimationDuration}}')),
transition(
'* => enter',
group([
animate('{{enterAnimationDuration}}'),
query('@*', animateChild(), {optional: true}),
]),
),
transition(
'* => exit, * => void',
group([
animate('{{exitAnimationDuration}}'),
query('@*', animateChild(), {optional: true}),
]),
),
]),
],
host: {
Expand Down
13 changes: 11 additions & 2 deletions src/material/bottom-sheet/bottom-sheet-animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
transition,
trigger,
AnimationTriggerMetadata,
group,
query,
animateChild,
} from '@angular/animations';
import {AnimationCurves, AnimationDurations} from '@angular/material/core';

Expand All @@ -25,11 +28,17 @@ export const matBottomSheetAnimations: {
state('visible', style({transform: 'translateY(0%)'})),
transition(
'visible => void, visible => hidden',
animate(`${AnimationDurations.COMPLEX} ${AnimationCurves.ACCELERATION_CURVE}`),
group([
animate(`${AnimationDurations.COMPLEX} ${AnimationCurves.ACCELERATION_CURVE}`),
query('@*', animateChild(), {optional: true}),
]),
),
transition(
'void => visible',
animate(`${AnimationDurations.EXITING} ${AnimationCurves.DECELERATION_CURVE}`),
group([
animate(`${AnimationDurations.EXITING} ${AnimationCurves.DECELERATION_CURVE}`),
query('@*', animateChild(), {optional: true}),
]),
),
]),
};
13 changes: 11 additions & 2 deletions src/material/dialog/dialog-animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
transition,
trigger,
AnimationTriggerMetadata,
query,
animateChild,
group,
} from '@angular/animations';

/**
Expand All @@ -30,11 +33,17 @@ export const matDialogAnimations: {
state('enter', style({transform: 'none'})),
transition(
'* => enter',
animate('150ms cubic-bezier(0, 0, 0.2, 1)', style({transform: 'none', opacity: 1})),
group([
animate('150ms cubic-bezier(0, 0, 0.2, 1)', style({transform: 'none', opacity: 1})),
query('@*', animateChild(), {optional: true}),
]),
),
transition(
'* => void, * => exit',
animate('75ms cubic-bezier(0.4, 0.0, 0.2, 1)', style({opacity: 0})),
group([
animate('75ms cubic-bezier(0.4, 0.0, 0.2, 1)', style({opacity: 0})),
query('@*', animateChild(), {optional: true}),
]),
),
]),
};

0 comments on commit 5edcc68

Please sign in to comment.