Chr*_*oth 6 javascript animation angular angular-animations
我创建了div.parent
一个效果很好的Angular动画元素()。当我向其添加子元素并尝试同时为其设置动画时,其中一个动画最终不会运行(它只是捕捉到新状态)。
Stackblitz: https ://stackblitz.com/edit/angular-2tbwu8
标记:
<div [@theParentAnimation]="state" class="parent">
<div [@theChildAnimation]="state" class="child">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
动画:
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)' ),
] ),
] ),
Run Code Online (Sandbox Code Playgroud)
看起来您不需要使用,query( ':self', ...
因为您正在使用group()
动画将并行运行。您可以在父级动画中更改转场:
transition('* <=> *', [
group([
query('@theChildAnimation', animateChild()),
animate('0.9s cubic-bezier(0.55, 0.31, 0.15, 0.93)'),
]),
]),
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3534 次 |
最近记录: |