javascript - Disable web page navigation on swipe(back and forward) -
on windows phone, in ie users can go , forward swiping on screen if swipe coming edge. os level functionality hampering webpage's ux.
is there js or css can disable that? hack do.
a snapshot windowsphone's website:
here link reference page: http://www.windowsphone.com/en-in/how-to/wp8/basics/gestures-swipe-pan-and-stretch
please note still need touchaction enabled horizontal scrolling.
copy , paste javascript:
var xpos = null; var ypos = null; window.addeventlistener( "touchmove", function ( event ) { var touch = event.originalevent.touches[ 0 ]; oldx = xpos; oldy = ypos; xpos = touch.pagex; ypos = touch.pagey; if ( oldx == null && oldy == null ) { return false; } else { if ( math.abs( oldx-xpos ) > math.abs( oldy-ypos ) ) { event.preventdefault(); return false; } } } );
if want minified, copy , paste this:
var xpos=null;var ypos=null;window.addeventlistener("touchmove",function(event){var touch=event.originalevent.touches[0];oldx=xpos;oldy=ypos;xpos=touch.pagex;ypos=touch.pagey;if(oldx==null && oldy==null){return false;}else{if(math.abs(oldx-xpos)>math.abs(oldy-ypos)){event.preventdefault();return false;}}});
Comments
Post a Comment