javascript - Avoid 2-finger scroll to trigger back/forward -


i'm trying find way avoid triggering back/forward in browser when user uses 2-finger scroll (eg: osx).

just this: https://tweetdeck.twitter.com

mobile devices notoriously annoying handling touch events. however, if return false or preventdefault() on dom touch event prevent browser scrolling/zooming/navigating.

the below example prevent touches executing default behavior; meaning link touches won't register, scrolling won't work etc.

$("body").on("touchstart", function(e){ e.preventdefault(); });

the following prevent default functionality of multi touch.

$("body").on("touchstart", function(e){ if (e.originalevent.touches.length == 2) { e.preventdefault(); } });

if need allow user click links, along lines of following.

$("body").on("touchstart", function(e){ if (e.target.tagname != "a") { e.preventdefault(); } });


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -