Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Events-- 'mouseup' not firing after mousemove

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!

like image 590
user1241091 Avatar asked Feb 29 '12 20:02

user1241091


People also ask

How do I trigger a mouseup event?

The mouseup event occurs when the left mouse button is released over the selected element. The mouseup() method triggers the mouseup event, or attaches a function to run when a mouseup event occurs. Tip: This method is often used together with the mousedown() method.

Does mouseup fire before click?

Mouseup is always firing before click, despite this order.

How do I get rid of mouseup event?

If you wish suppress the click event you have add the statement event. preventDefault() in the click event handler only and not the mouseup event handler.

Which event is generated when a mouse moves over a text?

The mouseover event occurs when a mouse pointer comes over an element, and mouseout – when it leaves.


2 Answers

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

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

like image 120
user1241091 Avatar answered Sep 20 '22 13:09

user1241091


Strangely, I've found that when I set my text as unselectable using the below CSS, that inhibits the mouseup event from firing as well -- perhaps this will help someone else.

-moz-user-select: none; -khtml-user-select: none; user-select: none; 
like image 44
TimDog Avatar answered Sep 19 '22 13:09

TimDog