Swiper.autoplay.paused and Swiper.autplay.true both return true even tho it shouldn't

Viewed 14

Im using swiper.js to create a looped news bar and I want the autoplay to be stoped on mouseEnter I previously used the autoplay.stop() method the only problem is it stops only in the end of the slide meaning its not instant, I also tried .setProgress(0,1000000), that kinda worked but then it had other issues like super speed on mouse leave and stuck on last slide.

 let barOptions = {
    spaceBetween: 0,
    centeredSlides: true,
    speed: 10000,
    autoplay: {
      delay: 0,
    },
    loop: true,
    loopedSlides: 6,
    slidesPerView: "auto",
    allowTouchMove: false,
    disableOnInteraction: true,
    watchSlidesProgress: true,
  };
  let newsSwiper = new Swiper(".newsBarSlider", barOptions);

  $(".newsBarSlider").mouseenter(function() {
    newsSwiper.setProgress(0, 10000000);
    console.log(newsSwiper.autoplay.paused);
    console.log(newsSwiper.autoplay.running);
  });

  $(".newsBarSlider").mouseleave(function() {
    newsSwiper.autoplay.run()
    console.log(newsSwiper.autoplay.paused);
  });
0 Answers
Related