【发布时间】:2013-03-19 23:27:34
【问题描述】:
我见过很多涉及停止所有 touchmove 事件的解决方案。但是,这对我不起作用,因为我的应用程序涉及绘图画布。有没有办法确保用户不能滚动,同时保留其他触摸事件? --阿什利
【问题讨论】:
标签: javascript jquery ipad
我见过很多涉及停止所有 touchmove 事件的解决方案。但是,这对我不起作用,因为我的应用程序涉及绘图画布。有没有办法确保用户不能滚动,同时保留其他触摸事件? --阿什利
【问题讨论】:
标签: javascript jquery ipad
您可以在绘图处理程序中使用e.preventDefault(),或者在附加到 DOM 树更上方的处理程序中使用。这只是防止touchmove 的默认行为是滚动。
$('body, html').on('touchmove', function(e){
e.preventDefault();
});
您仍然可以在绘图画布上处理 touchmove 事件。
另一种选择是在您的 CSS 中设置 overflow:hidden - 但这取决于您的页面大小。
【讨论】:
我认为你应该看看这个答案.. Prevent touchmove default on parent but not child
将您的画布放入容器中并停止在父级上滚动。
$('body').delegate('#fix','touchmove',function(e){
e.preventDefault();
}).delegate('.scroll','touchmove',function(e){
e.stopPropagation();
});
【讨论】: