我最近开始使用一个非常棒的插件将触摸平均转换为鼠标点击。但就在今天,我遇到了一个问题
jQuery('.draggable').click(function(){
alert('clicked');
})
要发出警报,我需要进行两次触摸(移动设备),而在计算机上我只需要点击一下鼠标。可能是什么问题?谢谢。
答案 0 :(得分:0)
// 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...
}
});