0
如果我有一个侦听touchend
事件的div,如果用户触摸div然后滚动或触摸移动,如何停止touchend事件触发?如果touchmove发生,停止任何触发事件触发
目前即时通讯做:
$('body').on('touchmove', function(){dragging = true}).on('touchend', function(){dragging = false})
,然后将每个touchend
事件我有用途:
if(dragging == false){ //do stuff}
,但我不希望有if语句添加此每touchend
事件我有(有很多)。
我也试过:
$('body').on('touchmove', function(event){
event.preventDefault()
event.stopPropagation()
event.stopImmediatePropagation()
return false;
})
,但这并没有阻止任何touchend
事件滚动或touchmove后射击。
我不认为你在'touchmove'中做的任何事情都可以让你防止'touchend'形式发射。基于标志的解决方案是唯一可行的解决方案。 – techfoobar