Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 + Is Playing Status
  • Loading branch information
EnricoMessall committed Mar 4, 2023
1 parent fa4a718 commit d6dea21
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/app/components/carousel/carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ export class Carousel implements AfterContentInit {

interval: any;

playing: boolean;

isCreated: boolean;

swipeThreshold: number = 20;
Expand Down Expand Up @@ -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 = '';
Expand Down

0 comments on commit d6dea21

Please sign in to comment.