Jquery – Scroll event on touchmove with jquery

ipadjqueryscrolltouch

I am currently working on something that uses $(window).bind('scroll' but the problem I am having is that on iPad and other touch devices the scroll event is only fired when the users stops moving and removes their finger. I have tried using touchmove but can't figure out how to get $(window).scrollTop() accurately. Does anyone have any ideas?

Best Answer


See this answer for reference

Though both of the following methods should work, the preferred method is...

...for Jquery version 1.7 and later:

$('body').on({
'touchmove': function(e) { 
    console.log($(this).scrollTop()); // Replace this with your code.
}
});

...or earlier

$('body').bind('touchmove', function(e) { 
console.log($(this).scrollTop()); // Replace this with your code.
});

Note that: "This should give you a consistent stream of the scrollTop value when the user scrolls, but be careful as it's going to fire even while the user is just holding his finger on the screen."