0
我最近开始使用一个很棒的插件来将触摸转换为鼠标点击。不过,就在今天我遇到一个问题触摸冲 - 转换点击触摸
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...
}
});