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);
});
I solved myself.
By using slideToClickedSlide()
, instead of slideTo()
, it is no longer interrupted.
© 2024 OneMinuteCode. All rights reserved.