2013-03-19 64 views
0

我见过很多涉及停止所有touchmove事件的解决方案。然而,这不适用于我,因为我的应用程序涉及绘图画布。有没有办法确保用户不能滚动,同时保留其他touchevents? --Ashley禁用滚动网页iPad

回答

1

您可以在您的绘图处理程序中使用e.preventDefault(),或者在DOM树的后面附加一个处理程序。这只是防止要滚动的touchmove的默认行为。

$('body, html').on('touchmove', function(e){ 
    e.preventDefault(); 
}); 

您仍然可以在您的绘图画布上处理touchmove事件。

另一种选择是在您的CSS中设置overflow:hidden - 但这取决于您的页面大小。

0

我想你应该看看这个答案.. Prevent touchmove default on parent but not child

把你的画布容器和停止滚动父。

$('body').delegate('#fix','touchmove',function(e){ 

    e.preventDefault(); 

}).delegate('.scroll','touchmove',function(e){ 

    e.stopPropagation(); 

});