开发者

PhoneGap + iOS Prevent default scroll action begins from input text field

I've faced up with the following problem:

I have a scroll area which contains list of input text fields.

I use

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

to prevent global scroll of the page. It works fine 开发者_如何学Cexcept cases when gesture begins from input field.

How can I prevent global scroll of the page when first touch traps to the input field?

Thanks.


I believe you want to capture the touchmove event using the addEventListener function so that the even doesn't "bubble". Try this:

/* 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);


this might help

the section "MORE SPECIALIZED SOLUTION" might be what you are looking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜