PhoneGap + iOS Disable default scroll action starts with input text box

I ran into the following problem:

I have a scroll pane that contains a list of text input fields.

I use

ontouchmove = function(e){ e. preventDefault(); } 

to prevent global page scrolling. It works great, except when the gesture begins with an input field.

How to prevent global page scrolling the first time you touch traps in the input field?

Thank.

+5
source share
2 answers

I believe that you want to capture the touchmove event using the addEventListener function so that the parity does not “bubble”. Try the following:

/* This code prevents users from dragging the page */
var preventDefaultScroll = function(event) {
  event.preventDefault();
  window.scroll(0,0);
  return false;
};
document.addEventListener('touchmove', preventDefaultScroll, false);
+3
source

this

" " , .

-1

All Articles