javascript-events--'mouseup'在mousemove之后没有触发 [英] javascript-events-- 'mouseup' not firing after mousemove

查看:376
本文介绍了javascript-events--'mouseup'在mousemove之后没有触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用javascript(没有库)拖动图像。我能听到mousedown和mousemove事件。出于某种原因,我无法在mousemove之后捕获mouseup事件。 (如果是点击,我可以捕获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!!! Thanks!

推荐答案

发现问题,如果它对任何人都有帮助:

Found the issue, if it is going to be of help to anyone:

我在 mousedown 事件中添加了 event.preventDefault(); 现在我得到 mouseup 通知。

I added event.preventDefault(); in the mousedown event and now I am getting mouseup notifications.

这篇关于javascript-events--'mouseup'在mousemove之后没有触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆