robnyman / domassistant

Automatically exported from code.google.com/p/domassistant
1 stars 0 forks source link

Mousemove en mouseup events don't fire on the document (after being removed and then added again) #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run this html:
<html>
<head>
<script src="DOMAssistantCompressed-2.8.js" type="text/javascript"></script>
<script type="text/javascript">
  DOMAssistant.DOMReady("init()");
  function init() {
    var draggable=$$("draggable");
    draggable.addEvent("mousedown", startDragMouse);
  }
  function startDragMouse(e) {
    $$("message").addContent(e.type+" on "+this.id+"<br>"); //log event
    $(document).addEvent("mousemove", dragMouse);
    $(document).addEvent("mouseup", releaseElement);
  }
  function dragMouse(e) {
    $$("message").addContent(e.type+" on "+this.id+"("+e.clientX+","+e.clientY+")"); //log 
event
  }
  function releaseElement(e) {
    $$("message").addContent("<br>"+e.type+" on "+this.id+"<br>"); //log event
    $(document).removeEvent("mousemove", dragMouse);
    $(document).removeEvent("mouseup", releaseElement);
  }
</script>
</head>
<body>
<div id="draggable" style="border: 1px solid black;">draggable</div>
<br><br>log:<br>
<div id="message" style="border: 1px solid black;"></div>
</body>
</html>

2. Mousedown on the draggeble. Keep your left mouse buttons pressed and start 
to move.
3. Notice the mousedown event on the element being fired.
4. Notice all subsequent mousemove on document being fired.
6. Now, mouse up (release left mouse button).
7. Notice the mouseup event on document being fired.
8. So far al works as expected
9. Now, here it comes. Mousedown again on the draggable and keep your left 
mouse buttons 
pressed and start to move....

What is the expected output? What do you see instead?
I would expect to have more subsequent mousemove events on the document after 
step 9. But 
they don't fire (I don't see them in the log div). Also no mouseup event on the 
document.

What version of the product are you using? On what operating system?
I'm using domassistant - Revision 497. It happens on Windows XP on IE7, 
Chrome2, Safari3 
and FF3.

Please provide any additional information below.
This script (above html) works as expected in 2.7.4!

(I think somehow removing the events mousemove and mouseup from the document, 
prevents 
those events to be added to the document again later...)

Original issue reported on code.google.com by ellen.es...@gmail.com on 21 Jul 2009 at 3:19

GoogleCodeExporter commented 9 years ago
(Issue was by c.westerbeek, I was logged in with someone elses google account)

I can make the code to reproduce the problem much simpler:

    $(document).addEvent("mousemove", dragMouse);

Now, mousemove fires.

    $(document).removeEvent("mousemove", dragMouse);
    $(document).addEvent("mousemove", dragMouse);

Now it doesn't.

With I'm using domassistant 2.8 - Revision 497 on any browser (I could use)

Original comment by c.wester...@gmail.com on 21 Jul 2009 at 3:39

GoogleCodeExporter commented 9 years ago
Fixed in r498 - it actually affected any events on any elements :(

Thanks Chris for the bug report!

Original comment by chengh...@gmail.com on 21 Jul 2009 at 4:08

GoogleCodeExporter commented 9 years ago
Fix confirmed on all browsers! Thank's for picking it up so quickly. Now I can 
use 
DOMAssistant 2.8 for my app's drag and drop feature.

Original comment by c.wester...@gmail.com on 21 Jul 2009 at 4:56