Swiper.js - Add class when transform finishes

Viewed 343

I can't find information in the documentation about adding a class right after the slide loads. The problem is that swiper.js adds the 'swiper-slide-active' class, but at the time of sliding! And I need to add some class when the slide finishes its animation ... as if "idle" after the end of the slide animation.

is it even possible?

var mySwipper = new Swiper('.my-swiper', {
  slidesPerView: 3,
  slidesPerColumn: 2,
  spaceBetween: 30,
  slidesPerGroup: 3,
  speed: 800,
  autoplay: {
    delay: 3000
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css" />
<script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
<div class="my-swiper">
  <div class="swiper-slide">
    <span>1</span>
  </div>
  <div class="swiper-slide">
    <span>2</span>
  </div>
  <div class="swiper-slide">
    <span>3</span>
  </div>
</div>

1 Answers

I found solution if someone else is looking for.

swiper.on('slideChangeTransitionEnd', function () {
//do something
}
Related