scooterlord
scooterlord

Reputation: 15349

touchswipe swipe along with click function on the same element

is it possible to utilize touchswipe on an element that already has a click function?

$('#myelem').click(function() {
 // do stuff
});

I tried using:

$('#myelem').on ('click swipe', function() {
// do stuff
});

..but I don't know how to load touchswipe's options then. :/

Also, is it possible to have touchswipe on an image element?

I would be greatful for any help I can get.

Upvotes: 1

Views: 4399

Answers (1)

Gareth
Gareth

Reputation: 19

I was having a similar problem but only on android devices. I managed to get it working with TouchSwipe-Jquery-Plugin https://github.com/mattbryson/TouchSwipe-Jquery-Plugin and the following code:

$('#myelem').swipe( {

    click:function(event,target){
        myFunction();
    },                                          
    swipeLeft: function() {
        myFunction();
    },
    swipeRight: function() {
        // do something on right swipe
    },
    allowPageScroll: 'vertical'
});

function myFunction() {
    // do something
};

more info

Upvotes: 1

Related Questions