简体   繁体   English

mousedown和mouseup事件处理程序的问题

[英]Issue with mousedown and mouseup event handlers

I have a drag and drop functionality on a page. 我在页面上有拖放功能。 I have defined a mousedown , mousemove , and mouseup event handlers to do it. 我已经定义了mousedownmousemovemouseup事件处理程序来做到这一点。 However, sometimes, in the browser (I haven't been able to narrow it down to one because it has happened on all of them at some point), when the user clicks (and lets go) on the object to drag, he is now dragging the object and has to click again (and let go) to release the object. 但是,有时候,在浏览器中(我无法将其缩小到一个,因为在某个时刻所有的浏览器都发生了这种情况),当用户单击(放开)要拖动的对象时,他就是现在拖动对象,必须再次单击(放开)以释放对象。

The intended functionality is for the user to click down and hold while dragging, letting go of the click only when he wants to release the object he is dragging. 预期的功能是供用户在拖动时单击并按住,仅当他要释放要拖动的对象时才松开单击。 Is there something I can add inside the mousemove handler to check if the mousedown is still active? 我可以在mousemove处理函数中添加一些内容来检查mousedown是否仍处于活动状态吗?

It's old but it may still help you I guess. 它很旧,但我猜它可能仍然可以帮助您。 Otherwise just use jQueryUI Drag'n'Drop-Plugin. 否则,只需使用jQueryUI Drag'n'Drop-Plugin。

JavaScript: Check if mouse button down? JavaScript:检查鼠标按钮是否按下?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM