Reputation: 939
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?
Upvotes: 4
Views: 13250
Reputation: 21
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."
Upvotes: 2