0

I am trying to create a progress bar for an image carousel on hover. When the carousel reaches its end the progress bar also should reset but it doesn't.

What I do is remove the style of width and transition when the carousel ends and add it back.

Here is the code. I am doing it in vuejs.

if (!nextSlide) {
          this.carouselProgress.style.transition = "none";
          this.carouselProgress.style.width = 0 + "%";
          currentSlide.classList.remove("current-slide");
          this.initialSlide.classList.add("current-slide");
          nextSlide = this.initialSlide;
          this.carouselProgress.style.width = 100 + "%";
          this.carouselProgress.style.transition = `width ${
              1.5 * numberOfSlide
          }s ease-in`;
        }

You can see in the first 2 lines and last 2 lines in the if statement how I am removing and reapplying the styles but it does not work.

Can anyone suggest me an alternate solution.

Saaransh Menon
  • 387
  • 3
  • 11

0 Answers0