我正在尝试为元素列表实现级联动画。
由于文档,我成功应用了状态触发器,但是所有元素状态都是同时应用的,而不是级联的。
我的动画:
预期结果:
hero.component.ts
trigger('flyInOut', [
state('in', style({
transform: 'translateX(0)'
})),
transition('void => in', [
style({transform: 'translateX(-100px)'}),
animate(500)
]),
transition('* => void', [
style({transform: 'translateX(0)'}),
animate(500)
])
])
hero.component.html
<li *ngFor="let hero of heroes"
(click)="onSelect(hero)"
[class.selected]="hero === selectedHero"
@heroState="hero === selectedHero ? 'active' : 'inactive'"
@flyInOut="'in'"
>
<span class="badge">{{hero.id}}</span> {{hero.name}}
<button class="delete" (click)="delete(hero); $event.stopPropagation()">
x
</button>
</li>