Search code examples
jquery-pluginstouchgesturejquery

Get the direction (up/down) in which the user is scrolling on an IPad (touchmove event)


I have following scenario:

I have a code, binded to the mousewheel event

$('#main').bind("mousewheel",function(ev, delta) {
    ev.preventDefault();
    if(delta == '-1') {
        alert("The user is trying to scroll upwards");
    } else {
        alert("The user is trying to scroll down");
    }
});

I then included this Plugin which provides the use of Iphone/Ipad touch events.
Look at following code:

$('#main').bind('touchmove', function(event) {
    ev.preventDefault();
});

I want to alert the direction in which the user is scrolling. How can I do this?

Thanks in advance!


Solution

  • Try using this awesome library.

    jQuery('#swipe').bind('swipeup',eventHandler);
    jQuery('#swipe').bind('swipedown',eventHandler);
    

    More info: http://jgestures.codeplex.com/