Closed Bug 1303 Opened 26 years ago Closed 26 years ago

[BLOCK] Can't move positioned elements with mousemove/clientX detection

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P2)

x86
Windows 95
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: angus, Assigned: joki)

Details

Here's a test case. When viewing this, you should see a blue box. You should be able to mousedown on the box and drag it around. When dragging, the delta movements are dumped via alert. In other words, if you move your mouse to the right a few pixels, the stdout will say "Moving by: (5,0)" or something like that to indicate it is trying to shift the DIV to the right by five pixels. However, the DIV never moves. Upon closer inspection of the output, you'll see that every mousemove event seems to cancel out the last one out: Moving by: (5,0) Moving by: (-5,0) Moving by: (10,-2) Moving by: (-10,2) ... etc. ... Here's the test case / sample code. I bet it has something to do with e.clientX/e.clientY <html> <head> <script> function doDrag(e) { var difX = e.clientX-window.lastX; var difY = e.clientY-window.lastY; alert('moving by: ('+difX+','+difY+')\n'); var newX = parseInt(document.getElementById("myElement").style.left)+difX+"px"; var newY = parseInt(document.getElementById("myElement").style.top)+difY+"px"; document.getElementById("myElement").style.left=newX; document.getElementById("myElement").style.top=newY; window.lastX = e.clientX; window.lastY = e.clientY; } function beginDrag(e) { window.lastX=e.clientX; window.lastY=e.clientY; window.onmousemove=doDrag; window.onmouseup=endDrag; } function endDrag(e) { window.onmousemove=null; // No equiv to releaseEvents in W3C DOM? alert("\n Ending drag \n"); } </script> </head> <body> <div id="myElement" onmousedown="beginDrag(event);" style="position: absolute; left: 40px; top: 40px; width: 100px; background-color: blue;"> Test one two three </div> </body> </html>
Status: NEW → ASSIGNED
So with the recent event changes this is a whole lot closer to working. There seems to be two problems now. One, when you're over the div, the movement is jumpy which probably indicates some sort of feuding coordindate systems. Two, once the mouse leaves the div, all the events come through in the document coord system. This makes the div drag around okay but the mouse isn't actually over the div.
Setting all current Open/Normal to M4.
per leger, assigning QA contacts to all open bugs without QA contacts according to list at http://bugzilla.mozilla.org/describecomponents.cgi?product=Browser
QA Contact: 4015 → 3847
QA contact re-assigned according to the product areas we're currently working on.
Target Milestone: M4 → M5
Coordinate problems will be fixed but the change is too unstable for M4.
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
Fixed. Here's some test code. <HTML> <BODY> <div onclick="dump('click div 1\n');"> Div 1 </div> <div style="position: absolute; top: 100px; left: 100px;" onclick="dump('click div 2\n');"> Div 2 </div> </BODY> </HTML>
Oops, wrong bug.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Status: REOPENED → ASSIGNED
Target Milestone: M5 → M6
Moving out to M7
Severity: normal → blocker
Summary: Can't move positioned elements with mousemove/clientX detection → [BLOCK] Can't move positioned elements with mousemove/clientX detection
Upgrading this to a blocker bug.
Okay, the big stopper here was just the bad clientx/y coords in subviews. All fixed now. You may need to take the alert out of the test to verify the fix but you can then happily drag the layer, oops, div (dhtml flashback, I believe I fixed this same bug about two years ago) all over the page.
Whiteboard: just need to mark fixed?
I see a checkin from joki and comment above but the bug isn't marked fixed yet. can we do that base on the update to mozilla/layout/ events/src/nsDOMEvent.cpp or other earlier checkin? Fixing event clientx/y coords to have the right value even in subviews
Status: ASSIGNED → RESOLVED
Closed: 26 years ago26 years ago
Resolution: --- → FIXED
Sorry, that last commment from me was supposed to accompany setting the bug fixed but I forgot the last part.
Status: RESOLVED → VERIFIED
Whiteboard: just need to mark fixed?
Tested using 6/16 build. Viewer works correctly. Per joki@netscape.com, I had to remove the alerts for test to work in Apprunner. Verifying bug fixed.
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.