阻止应用程序拖动,但允许滚动ios中的内部div元素 [英] prevent app dragging but permit scroll of inner div elements in ios

查看:147
本文介绍了阻止应用程序拖动,但允许滚动ios中的内部div元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Phonegap适应iOS5的网络应用程序。除了一个问题以外,一切都正常:



我的内部< div> 如果在Chrome中溢出,则滚动完全不会在iPad上滚动。



- 我禁用了通过禁用touchmove拖动应用程序;
--i已经实现了(可能不正确?)-webkit-overflow-scrolling:触摸CSS属性,这显然是iOS5的新特性,如下所示:



overflow:scroll;
-webkit-overflow-scrolling:touch;

没有什么可行的。



如果我注释掉禁用应用程序拖动的javascript(例如touchmove),然后滚动工作,但它拖动并滚动整个应用程序。



任何帮助都可以感谢。

解决方案

我可以通过使用下面的代码来阻止拖放主应用程序/页面。 b
$ b

  var myDiv = document.getElementById('idMyDiv'); 

myDiv.addEventListener('touchmove',function(e){
e.preventDefault();
},false);


I have a web app that I am adapting to iOS5 using Phonegap. Everything works except for one issue:

My inner <div>s, which are set to scroll if overflowed and scroll perfectly if overflowed in Chrome do not scroll at all on the iPad.

--I have disabled app dragging by disabling touchmove; --i have implemented (perhaps incorrectly?) the -webkit-overflow-scrolling:touch CSS property that is, apparently, new to iOS5 like so:

overflow: scroll; -webkit-overflow-scrolling:touch;

Nothing seems to work.

If I comment out the javascript (from Phonegap) that disables app dragging (ie. touchmove), then the scrolling works but it drags and scrolls the entire app.

Any help would be appreciated.

解决方案

I was able to prevent dragging of the main app/page by using the following code:

var myDiv = document.getElementById('idMyDiv');

myDiv.addEventListener('touchmove', function (e){
    e.preventDefault();
}, false);

这篇关于阻止应用程序拖动,但允许滚动ios中的内部div元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆