I have a site that needs to work on mobile devices. If I touch a link while attempting to scroll down the page, it triggers the touchstart event (in most cases loading a new window, but in the case of the header, navigating through the menu). I want to be able to scroll without touchstart events being triggered. How can I accomplish this?
Asked
Active
Viewed 1,232 times
0
-
This may answer your issue http://stackoverflow.com/questions/31010659/phonegap-mobile-app-tapping-while-scrolling-selects-incorrect-item – Ed Ballot Jul 14 '15 at 18:58
-
No, that seems like a different issue. – Erica Stockwell-Alpert Jul 14 '15 at 19:08
1 Answers
0
I've figured out a solution that works for most clickable items on the page:
$(document).bind("touchstart", function (e) {
touchStartPos = $(window).scrollTop();
}).bind("touchend", function (e) {
var distance = touchStartPos - $(window).scrollTop();
if (distance > 20 || distance < -20) {
e.preventDefault;
}
});
A few items on my page seem to not get bound, but you can just specifically bind each item as needed in addition to doing a general $(document).bind().

Erica Stockwell-Alpert
- 4,624
- 10
- 63
- 130