I have a component called header.component and I need to call a method when a css animation finishes.
I have seen a lot of examples where you can use the following syntax
<div class="header-div" (@anim.done)="onAnimationFinish($event)"></div>
to call method onAnimationFinish (defined in the header.component.ts file). However, this will only work if you have defined a trigger in the .ts file.
I would like to keep my animations and transitions defined in the .css file so my question is:
is there any way to define an animation trigger that will be linked to a @keyframe animation in the header.component.css file or is it 100% compulsory that I define my css animations with triggers when using Angular 2?
My css:
@keyframes anim {
0% { position:relative; width: 50px; left: 0px; }
50% { position:relative; width: 100px; left: -25px; }
100% { position:relative; width: 50px; left: 0px; }
}
The .ts file only contains the function that should be called when animation 'anim' finishes.
Thanks.