我正在尝试使用动态列表在我的应用中错开动画。如果可能的话,我想动画进入和离开,但只是为了让进入工作。
animations: [
trigger('slideIn', [
transition(':enter', [
style({
transform: 'translate3d(0,-10px,0)',
opacity: 0
}),
animate('0.1s', style({
transform: 'translate3d(0,0,0)',
opacity: 1
}))
])
])
]
上面是我无法运行的动画代码,下面是我如何将其实现到模板中。
<ion-content [@listAnimation]="eventsList?.length">
<ion-list>
<event-item *ngFor="let item of eventsList" [item]="item"></event-item>
</ion-list>
<empty-list [list]="eventsList" [message]="'There are no event items to display.'"></empty-list>
<ion-infinite-scroll [enabled]="infiniteScroll === null" (ionInfinite)="doInfinite($event)">
<ion-infinite-scroll-content></ion-infinite-scroll-content>
</ion-infinite-scroll>
</ion-content>
请让我知道我哪里出错了。
答案 0 :(得分:3)
Haven尚未完成任何动画,但根据: https://www.yearofmoo.com/2017/06/new-wave-of-animation-features.html#space-things-out-with-stagger
您的代码应该是这样的:
animations: [
trigger('listAnimation', [
transition('* => *', [
// remember that :enter is a special
// selector that will return each
// newly inserted node in the ngFor list
query(':enter', [
style({
transform: 'translate3d(0,-10px,0)',
opacity: 0
}),
animate('0.1s', style({
transform: 'translate3d(0,0,0)',
opacity: 1
}))
])
])
]
即为您已经获得的内容添加query
级别
答案 1 :(得分:-1)
我意识到问题是什么。当一个for循环直接绑定在你必须将它设置为父div的组件上然后它完美地工作时,动画将不会运行/