我创建了一个元素(div.parent
)以及效果很好的 Angular 动画。当我向其中添加一个子元素并尝试同时为子元素设置动画时,其中一个动画最终不会运行(它只是捕捉到新状态)。
堆栈闪电战:
https://stackblitz.com/edit/angular-2tbwu8 https://stackblitz.com/edit/angular-2tbwu8
Markup:
<div [@theParentAnimation]="state" class="parent">
<div [@theChildAnimation]="state" class="child">
</div>
</div>
动画:
trigger( 'theParentAnimation', [
state( 'down', style( {
transform: 'translateY( 100% ) translateZ( 0 )',
} ) ),
transition( '* <=> *', [
group( [
query( ':self', [
animate( '0.9s cubic-bezier(0.55, 0.31, 0.15, 0.93)' ),
] ),
query( '@theChildAnimation', animateChild() ),
] ),
] ),
] ),
trigger( 'theChildAnimation', [
state( 'down', style( {
transform: 'translateY( 100% ) translateZ( 0 )',
} ) ),
transition( '* <=> *', [
animate( '0.9s cubic-bezier(0.55, 0.31, 0.15, 0.93)' ),
] ),
] ),