事件-鼠标移动后未触发“鼠标” [英] Events-- 'mouseup' not firing after mousemove
问题描述
我正在尝试使用Javascript(无库)拖动图像。我能够收听 mousedown
和 mousemove
事件。由于某些原因,在 mousemove
之后,我无法捕获 mouseup
事件。 (如果是单击,则可以捕获鼠标
,如果是拖动,则不能捕获)。
我试图听文档,窗口和图像上的事件。
这是我测试页的网址:
I am trying to drag an image with Javascript (no libraries). I am able to listen to mousedown
and mousemove
events. For some reason, I am not able to capture the mouseup
event after mousemove
. (I can capture mouseup
if it is a click but not if it is a drag).
I have tried to listen to the event on document, window, and the image.
Here's the url to my test page:
https://dl-web.dropbox.com/get/Public/move.html?w=74a0d498
在此方面的任何帮助将不胜感激!
Any help on this would be greatly appreciated!
推荐答案
找到了问题所在(如果要解决的话)对任何人的帮助:
Found the issue, if it is going to be of help to anyone:
我在 mousedown <中添加了
event.preventDefault();
/ code>事件,现在我收到 mouseup
通知。
I added event.preventDefault();
in the mousedown
event and now I am getting mouseup
notifications.
这篇关于事件-鼠标移动后未触发“鼠标”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!