i have traying to make a rotation animation over a group of images using the angular animation library but i can't make it work.
task:
- import the BrowserAnimationModule [done]
- import the animations functions in my component [done]
so this is the component code:
@Component({
selector: 't-animation',
templateUrl: './t-animation.component.html',
styleUrls: ['./t-animation.component.css'],
animations: [
trigger('imgAnimation', [
state("stop", style({ transform: 'rotateZ(0)' })),
state("a", style({ transform: 'rotateZ(90)' })),
state("b", style({ transform: 'rotateZ(180)' })),
transition('* => *', [style({ transform: 'rotateZ(90)' }), animate('100ms ease-in')]),
]),
]
})
export class TAnimationComponent implements OnInit {
running = true;
animation_state;
constructor() {
this.animation_state = "stop";
}
ngOnInit() {
this.startAnimation();
}
startAnimation() {
this.running = true;
this.animation_state = 'a';
}
stopAnimation() {
this.running = false;
}
}
the html code
<div class="images-container">
<img [@imgAnimation]="animation_state" [src]="'assets/img/animate-1.png'">
<img [@imgAnimation]="animation_state" [src]="'assets/img/animate-2.png'">
<img [@imgAnimation]="animation_state" [src]="'assets/img/animate-3.png'">
</div>
<button (click)="startAnimation()">toggle</button>
any advice?