I created the following animation:
fade.animation.ts:
import { Component } from '@angular/core';
import { trigger, state, animate, query, transition, style, stagger } from
'@angular/animations';
export let fade = trigger('fade', [
state('void', style({ opacity: 0 })),
transition(':enter, :leave', [
animate(2000)
])
]);
I'm using in the next component:
<div id="mpl_loader" class="divCabeceraTitulo">
<div class="lineaTitulo">
<div class="logoMinisterio" [@fade]>
<img src="assets/imagenes/SRDLOGO.png">
</div>
<div class="logoGesRepro">
<img class="imgGesRepro" src="assets/imagenes/gesReproB.png">
</div>
<div class="descripcionAplicacion">
<span>título</span>
</div>
</div>
</div>
The animation works, the problem is that it only runs once, when it loads the component, what I want is for it to do it "n" times. How do I it? Please help
A way to do it would be to use two states, that you would toggle, at the end of the previous animation, and this for as many time as you have defined.
animations.ts
app.component.html
Here is the important part :
[@fade]="state" **(@fade.done)**="onDone($event)"
app.component.ts
Finally, you increment the counter and toggle the state at the end of the previous animation :
Here is a StackBlitz example I created for this : https://angular-wekm96.stackblitz.io
(I applied the animation on the text)
Use keyframes with animation-iteration-count (configures the number of times the animation should repeat)