Possible to disable touch simulation for slides but not scrollbar (idangerous swiper)?

user1017882 picture user1017882 · May 21, 2014 · Viewed 18.8k times · Source

I have an idangerous swiper on my page which successfully simulates touch events on both the slides and accompanying scrollbar (allowing a mouse click and movement to slide slides left or right).

This is fine, but I've now called draggable on the slides within the swiper, which means I need to stop this touch simulation (dragging the slides and moving them at the same time is causing confusion) - but only on the slides, not the scrollbar (I still need the scrollbar to function as it did subsequent to a mouse click and movement).

What I've Tried

According to the API I can disable touch simulation:

var swiper = new Swiper('.swiper', {
    slidesPerView: 3,
    simulateTouch: false,
    scrollbar: {
        container: '.swiper-scrollbar',
        hide: false,
        draggable: true,
        snapOnRelease: true
    }
});

This works as expected, but on both the scrollbar and slides, which is no good.

I've also tried returning false from a number of the events the swiper api exposes:

var swiper = new Swiper('.swiper', { slidesPerView: 3, onTouchStart: function() { return false; }, scrollbar: { container: '.swiper-scrollbar', hide: false, draggable: true, snapOnRelease: true } });

This doesn't have any effect at all.

Answer

Tolgahan Özgür picture Tolgahan Özgür · Feb 26, 2016

Here is solution for Swiper-3.3.1

simulateTouch:false