Symeon Breen
Symeon Breen

Reputation: 1541

Prevent click firing after swipe on desktop browser

I am using touchswipe for a web app, but I would also like it to work on the desktop (specifically chrome). However it is firing the click after a swipe. Is there a way to prevent it doing this ?

I have a jsfiddle for this

    $(".swiper").swipe({
        tap: function(event, target) {
            alert('tap');
        },
        swipe:function(event, direction, distance, duration, fingerCount){
            alert('swipe');
        }
    });
    $(".swiper").on("click",function () {alert("click")});

I have tried return false , stopPropogation etc but to no avail.

Upvotes: 0

Views: 1348

Answers (1)

Keval Bhatt
Keval Bhatt

Reputation: 6322

Use Latest Js https://cdnjs.cloudflare.com/ajax/libs/jquery.touchswipe/1.6.4/jquery.touchSwipe.js

see this discussion

And git diff

Example: http://jsfiddle.net/kevalbhatt18/quycddab/1/

$(document).ready(function () {
    var swipFlag = false;
    $(".swiper").swipe({
        tap: function (event, target) {
            alert('tap');
        },
        swipe: function (event, direction, distance, duration, fingerCount) {
            console.log(event)

            alert('swipe');

        }
    });

});

Upvotes: 1

Related Questions