I am working on angular project , In this code below is for animation satellite meteorological images .
TOTAL = 20; // total number of images
currentIndex = 1;
constructor() {
}
ngOnInit() {
}
play() {
setInterval(() => {
console.log(this.currentIndex)
if (this.currentIndex + 1 > this.TOTAL) this.currentIndex = 1;
else this.currentIndex++
}, 400)
}
stop() {
}
html
<img src="/gulf_ksa1/{{currentIndex}}.jpg" name="animation" style="width:auto;" class="img-responsive">
<ion-button size="large" (click)="play()">تشغيل</ion-button>
<ion-button size="large" (click)="stop()">ايقاف</ion-button>
My code above is working fine with animating images , but what l want to do When user click on function stop , i want to get current Index even stop animating .
any idea please ?