I'm trying to have a stagger animation in a list. Up till now I have managed to have the stagger animation on load. Apart from on load I'd like to have the stagger animation trigger when new items are added to the array.
I followed this example: https://medium.com/google-developer-experts/angular-applying-motion-principles-to-a-list-d5cdd35c899e
And came up with a quick test: https://stackblitz.com/edit/angular-stagger-animation-test2
In the app.component.ts
I define the stagger animation and in the child.component.ts
I define the element's animation.
Stagger Animation:
trigger('list', [
transition(':enter', [
query('@animate',
stagger(250, animateChild())
)
])
])
The query('@animate')
gets the child component element, with the animateChild()
triggering the animation in the child component.
Child Animation:
trigger('animate', [
transition(':enter', [
style({ opacity: 0, transform: 'translateY(-10px)' }),
animate('250ms', style({ opacity: 1, transform: 'translateY(0px)' }))
]),
transition(':leave', [
style({ opacity: 1 }),
animate('250ms', style({ opacity: 0, transform: 'translateY(10px)' }))
])
])
The main difference in my case is that I'm adding multiple objects to the array at once. I don't know if it possible to have the new items enter the page in a staggered manner.