Swiper.js Interrupted Loop Time Termination

Asked 2 years ago, Updated 2 years ago, 45 views

As shown below, I try to focus on the center with slideTo when I click on the swiper, but it breaks when I go to the beginning or end.

It seems that the elements are cloned when a mouse drag or touchEvent is generated, but I would like to know if you know how to complete it with just a program.
After swiper.slideTo(), I added swiper.update() and tried various options with pear gravel.

let swiper=new Swiper('.swiper-container', {
    slidesPerView: 4.9,
    spaceBetween: -1,
    loop —true,
    grabCursor:true,
    centeredSlides: true,
    uniqueNavElements: true,
});

swiper.on('click', function(){
    swiper.slideTo(swiper.clickedIndex);
});

javascript jquery

2022-09-29 22:12

1 Answers

I solved myself.
By using slideToClickedSlide(), instead of slideTo(), it is no longer interrupted.


2022-09-29 22:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.