如何强制触发dragend
事件?我使用一个库,它自动向元素添加侦听器,查找长按(用于触摸屏模拟右键单击事件)。我不想让它在用户试图拖动时触发(但拖动的本质意味着,他们点击并按住/长按)
我知道如何设置,但是我想要的是
instrumentInfo.addEventListener("dragstart", function (e) {
e.preventDefault();//stop longpress working for touch screens
e.dragend(); //not going to work
instrumentInfo.dispatchEvent("dragend");//does not work
instrumentInfo.dispatchEvent(new Event("dragend"));//no exception but does not seem to work
}
我知道我可能会得到竞争条件,我很好
答案是,执行mouseup事件
instrumentInfo.dispatchEvent(new Event("mouseup"));