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