Skip to content Skip to sidebar Skip to footer

Swipeleft/swiperight Triggered During Vertical Scroll In Jquery Mobile

Problem is that swipeleft/swiperight event is trigger when I want vertical scroll. We are using jQuery mobile 1.1.0 version and jQuery 1.7.1. and code is: $(document).delegate('#q

Solution 1:

You can control how the swipe event works changing the values of the following object

$.extend($.event.special.swipe,{
  scrollSupressionThreshold: 10, // More than this horizontal displacement, and we will suppress scrolling.durationThreshold: 1000, // More time than this, and it isn't a swipe.horizontalDistanceThreshold: 30,  // Swipe horizontal displacement must be more than this.verticalDistanceThreshold: 75,  // Swipe vertical displacement must be less than this.
});

place it on your code before listening to the swipes. Change for example the verticalDistanceThreshold to 15 and the durationThreshold to 500 that will help to reduce the false positive.

On the other side, in your code you're triggering the click event on your buttons, while that works, a better approach would be to call directly the method that executes next/previous actions.

Good luck!

Post a Comment for "Swipeleft/swiperight Triggered During Vertical Scroll In Jquery Mobile"