javascript - Disable Vertical scroll on mobile devices -


i using touchmove, touchstart , touchend functions jquery mobile. trying disable vertical scroll while touchstart , enable when touchend triggered. have tried few things:

  • adding overflow: hidden body: works fine chrome browser doesn't work firefox android

  • binding , unbinding scrolling event body when touchstart event fired , touched fired - didn't work @ all(im sure did wrong). below code.

code:

$(document).on("touchstart", ".amount-container", function(event){     $(".notify-cart").addclass("show");     if(event.touches.length == event.changedtouches.length) {         monitor = {             x: event.touches[0].clientx,             y: event.touches[0].clienty         };     } }).on("touchend", ".amount-container", function(){     $(".notify-cart").removeclass("show");     $("body").removeclass("overflowhide");     monitor = {}; }).on("touchmove mousemove", ".amount-container", function(event){     if(math.abs(event.changedtouches[0].clientx - monitor.x) > math.abs(event.changedtouches[0].clienty - monitor.y)) {      }     else{         event.preventdefault();     } }); // prevent scrolling while swipe/touchmove var touchscroll = function( event ) {     event.preventdefault(); }; 

i tried few other things too. nothing worked in firefox. there better way solve problem. let me know if need else.

i'm not positive this'll work, try replacing

var touchscroll = function( event ) {     event.preventdefault(); }; 

with

document.body.addeventlistener('touchstart', function(e){e.preventdefault(); }); 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -