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