I have a list, where the items have an animation like this:
<li @animation>
And this is my animation trigger:
trigger('animation', [
transition(':enter', [
style({ height: '0px', 'padding-top': '0', 'padding-bottom': '0'}), // initial
animate('0.5s',
style({ height: '*', 'padding-top': '*', 'padding-bottom': '*'})) // final
]),
transition(':leave', [
style({ height: '*', 'padding-top': '*', 'padding-bottom': '*', opacity: 1}), // initial
animate('0.5s',
style({ height: '0px', 'padding-top': '0', 'padding-bottom': '0', opacity: 0})) // final
])
])
How can i conditionally turn on/off this animation for a specific item? Actually i look for sth. like this:
<li [@animation]=item.isAnimated>
which does not work at all.
And unfortunately Angular documentation has just a sentence about this:
For elements entering or leaving a page (inserted or removed from the DOM), you can make the animations conditional. For example, use *ngIf with the animation trigger in the HTML template.
But when i combine the animation annotation with a *ngIf, the not-animated items will obviously not be shown at all:
<li *ngIf="item.isAnimated" @animation>
I want to show all the items further on regardless of isAnimated flag. I just want to turn on/off the animation for a specific item.