[英]Touch punch - convert clicks to touches
我最近開始使用一個很棒的插件將觸摸均勻轉換為鼠標單擊。 但是就在今天,我遇到了一個問題
jQuery('.draggable').click(function(){
alert('clicked');
})
要發出警報,我需要進行兩次觸摸(移動設備),而在計算機上,我只需要單擊一下鼠標即可。 可能是什么問題? 謝謝。
// set a var as false as a way to change and flag if something is being dragged
var dragCheck = false;
$('.element').draggable({
revert: true,
drag: function(){
// On drag set that flag to true
dragCheck = true;
},
stop: function(){
// On stop of dragging reset the flag back to false
dragCheck = false;
}
});
// Then instead of using click use mouseup, and on mouseup only fire if the flag is set to false
$('.element') .bind('mouseup', function(){
if(dragCheck == false){
// do the click action here...
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.