gpt4 book ai didi

javascript - Angular 动画 : Animate Parent and Child Elements

转载 作者:数据小太阳 更新时间:2023-10-29 05:17:23 25 4
gpt4 key购买 nike

我用 Angular 动画创建了一个元素 (div.parent),效果很好。当我向它添加一个子元素并尝试同时为该子元素设置动画时,其中一个动画并没有结束运行(它只是捕捉到新状态)。

堆栈 Blitz : https://stackblitz.com/edit/angular-2tbwu8

标记:

<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)' ),
] ),
] ),

最佳答案

看起来您不需要使用 query( ':self', ... 因为您正在使用 group() 动画将并行运行。您可以更改父动画中的过渡:

transition('* <=> *', [
group([
query('@theChildAnimation', animateChild()),
animate('0.9s cubic-bezier(0.55, 0.31, 0.15, 0.93)'),
]),
]),

Updated StackBlitz

关于javascript - Angular 动画 : Animate Parent and Child Elements,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51067142/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com