0

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.

Symeon Breen
  • 1,531
  • 11
  • 25

1 Answers1

1

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');

        }
    });

});

Keval Bhatt
  • 6,224
  • 2
  • 24
  • 40
  • Thanks for your reply Keval. what i want to do is stop the click event of the .swiper element - see http://jsfiddle.net/symeon/quycddab/2/ you can see each time i swipe it also does the click. – Symeon Breen Jun 30 '15 at 10:09
  • yes i have one solution and i created first fiddle of that see this http://jsfiddle.net/symeon/quycddab/ in this fiddle i used your js – Keval Bhatt Jun 30 '15 at 11:14
  • Ahh ok - so you are just setting a flag - i did wonder if there was something within touchswipe that did this. thanks anyway. – Symeon Breen Jun 30 '15 at 11:33
  • because i tried with stop propagation prevent default and return false but its not working because your onclick and swip event both register separately . and so i think use new js which is mention in answer you can see diff of js they added tap for click so your click event and tap event both work – Keval Bhatt Jun 30 '15 at 11:45