0
在角度则可以错开动画,因为我在这里做,例如:仅使用Angular动画对列表中的新项目添加动画?
<div
masonryLayout
[masonryOptions]="masonryOptions"
[input]="photos"
class="grid"
[@photosAnimation]="photos.length"
>
<img
*ngFor="let photo of photos; let i = index"
(click)="onPhotoClick(photo)"
src="{{photo.photo.medium}}"
class="grid-item clickable hover-outline"
[ngClass]="[photo.addedToCart ? 'in-cart-icon':'']"
alt="{{photo.motive}}"
/>
</div>
我不断添加新项目上的需求列表,用户点击“显示更多照片”按钮实例。但是这会重新触发所有照片上的动画,我如何才能使列表的一部分错开?
编辑:我有两个不同的半解决方案,
1)第一张照片瞬间加载,随后的照片加载与交错:
animations: [
trigger('photosAnimation', [
transition('* => *', [
query(
':enter',
style({ opacity: 0, transform: 'translateY(-20%)' }),
{ optional: true }
),
query(
':enter',
stagger('100ms', [
animate('100ms', style({ opacity: 1, transform: 'translateY(0)' }))
]),
{ optional: true }
)
])
])
]
2)另一种选择重新动画所有当新的被添加到列表中的照片:
animations: [
trigger('photosAnimation', [
transition('* => *', [
query(
'*',
style({ opacity: 0, transform: 'translateY(-20%)' }),
{ optional: true }
),
query(
'*',
stagger('100ms', [
animate('100ms', style({ opacity: 1, transform: 'translateY(0)' }))
]),
{ optional: true }
)
])
])
]
无论这些半的解决方案完全满足我的愿望在第一列表都错开,并添加动画到名单。