From d6dea21c53933ed8f610c9998bccd6b89b39c515 Mon Sep 17 00:00:00 2001 From: Enrico Date: Sat, 4 Mar 2023 18:42:41 +0100 Subject: [PATCH] Issue #12706 + Is Playing Status --- src/app/components/carousel/carousel.ts | 26 +++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/app/components/carousel/carousel.ts b/src/app/components/carousel/carousel.ts index 63a78571cc0..7495792344c 100755 --- a/src/app/components/carousel/carousel.ts +++ b/src/app/components/carousel/carousel.ts @@ -220,6 +220,8 @@ export class Carousel implements AfterContentInit { interval: any; + playing: boolean; + isCreated: boolean; swipeThreshold: number = 20; @@ -604,23 +606,31 @@ export class Carousel implements AfterContentInit { } startAutoplay() { - this.interval = setInterval(() => { - if (this.totalDots() > 0) { - if (this.page === this.totalDots() - 1) { - this.step(-1, 0); - } else { - this.step(-1, this.page + 1); + if(!this.playing) { + this.interval = setInterval(() => { + if (this.totalDots() > 0) { + if (this.page === this.totalDots() - 1) { + this.step(-1, 0); + } else { + this.step(-1, this.page + 1); + } } - } - }, this.autoplayInterval); + }, this.autoplayInterval); + this.playing = true; + } } stopAutoplay() { if (this.interval) { clearInterval(this.interval); + this.playing = false; } } + isPlaying(){ + return this.playing; + } + onTransitionEnd() { if (this.itemsContainer) { this.itemsContainer.nativeElement.style.transition = '';