Javascript 只允许滚动一次<;部门>;移动电话

Javascript 只允许滚动一次<;部门>;移动电话,javascript,jquery,ios,mobile,touchmove,Javascript,Jquery,Ios,Mobile,Touchmove,使用web应用程序时,我希望防止屏幕四处移动,因此我从以下内容开始: $(document).on("touchmove", false); 。。。然后我意识到我有一个div,需要能够滚动,所以我添加了: $(document).on('touchmove', function(e) { if (!$(e.target).parents().hasClass( 'touch-moveable' )) { e.preventDefault(); } }); 工作正常,但现在在

使用web应用程序时,我希望防止屏幕四处移动,因此我从以下内容开始:

 $(document).on("touchmove", false);
。。。然后我意识到我有一个
div
,需要能够滚动,所以我添加了:

$(document).on('touchmove', function(e) {
  if (!$(e.target).parents().hasClass( 'touch-moveable' )) {
    e.preventDefault();
  }
});
工作正常,但现在在该div内的移动设备上滚动可能会导致整个屏幕再次移动。不是世界末日,而是。。。难道没有办法让一切都保持静止,只让一个div移动吗

编辑

好吧,这很管用,尽管我打赌它可以被整合,使之更加优雅

$(document).on('touchmove', function(e) {
  if (!$(e.target).parents().hasClass( 'touch-moveable' )) {
    e.preventDefault();
  }
});

$('.touch-moveable').on('touchmove',function(e){
  e.stopPropagation();
});

尝试
$('.'touch-moveable')。在('touchmove',函数(e){e.stopPropogation();)
Ugh,我不想说得太多,但请帮我一点忙。当涉及到preventDefault时,我对委派和stopPropagation非常困惑……我是在停止touchmove的传播,还是在停止preventDefault的传播?啊,明白了。谢谢@RayonDabreI,我很高兴它有帮助!Happy CodingPropagation拼写错误;倒数第二行应该是
e.stopPropagation();