gpt4 book ai didi

javascript - Angular 5 中的动画立即运行

转载 作者:行者123 更新时间:2023-12-01 02:38:38 26 4
gpt4 key购买 nike

我创建了一个具有两个状态和两个状态之间的转换的触发器

当我点击制作动画时,即使我输入 3000 毫秒的过渡时间,它也会立即运行

<div class="divv" [@goals]='stateExression'>
<mat-card class="example-card">
<mat-card-header>
<div mat-card-avatar class="example-header-image"></div>
<mat-card-title>Shiba Inu</mat-card-title>
<mat-card-subtitle>Dog Breed</mat-card-subtitle>
</mat-card-header>
<img mat-card-image src="https://material.angular.io/assets/img/examples/shiba2.jpg" alt="Photo of a Shiba Inu">
<mat-card-content>
<p>
Hello
</p>
</mat-card-content>
<mat-card-actions>
<button mat-button (click)="anim()">LIKE</button>
<button mat-button>SHARE</button>
</mat-card-actions>
</mat-card>
</div>

状态改变函数:

stateExression : string='inactive';

anim() {
if(this.stateExression === 'inactive')
this.stateExression ='expended';
else
this.stateExression = 'inactive';
}

动画触发器:

trigger('goals', [
state('inactive', style({
height: '300px'
})),
state('expended', style({
height: '0px'
})),
transition ('inactive <=> expanded',animate('2000ms'))

])
]

如何让过渡运行缓慢?

最佳答案

trigger('goals', [
state('inactive', style({
height: '300px'
})),
state('expended', style({
^^^^^^^^^^^
height: '0px'
})),
transition ('inactive <=> expanded',animate('2000ms'))
^^^^^^^^^^
])
]

状态名称不同 expandedexpended

关于javascript - Angular 5 中的动画立即运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47717350/

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