Hi,
I developed drag and drop functionality for my web app a while ago and it's been working fine. My app runs exclusively on IE 6 & 7. I have my own custom logic to capture mousedown and mouseup events on the elements you can drag, and I just create a ghost of the element to follow your mouse cursor around, the actual element being dragged never moves. The elements capable of being dragged were divs. But recently, I needed to make the change to use images, and that's where my problems started.
The drop targets are also divs/images, and I capture mouseovers/mouseouts to highlight them as drop targets.
So the problem I'm having is that since I switched to images, events fire normally until I try dragging an image. Once I do that, the events being fired make no sense anymore. It seems like mouseover/mouseout events are firing for the element being dragged when I hover over ANY other element. Those should only be firing when I mouse over or mouseout that particular element.
Here's a simplified example of what's happening:
Now when I start dragging image1 around, and I drag it over image2, the function mouseOverImage1 will get called. Very strange.
Even more curious, is that I've found out that by moving the focus away from the window, and then back onto it while I'm dragging an image, the event handlers begin firing as normal again. This is not a valid fix, but very odd behavior.
So I'm totally stumped. If anyone has any ideas, please help me out.
Thanks,
Adrian
I developed drag and drop functionality for my web app a while ago and it's been working fine. My app runs exclusively on IE 6 & 7. I have my own custom logic to capture mousedown and mouseup events on the elements you can drag, and I just create a ghost of the element to follow your mouse cursor around, the actual element being dragged never moves. The elements capable of being dragged were divs. But recently, I needed to make the change to use images, and that's where my problems started.
The drop targets are also divs/images, and I capture mouseovers/mouseouts to highlight them as drop targets.
So the problem I'm having is that since I switched to images, events fire normally until I try dragging an image. Once I do that, the events being fired make no sense anymore. It seems like mouseover/mouseout events are firing for the element being dragged when I hover over ANY other element. Those should only be firing when I mouse over or mouseout that particular element.
Here's a simplified example of what's happening:
Code:
var img1 = document.getElementById('image1');
var img2 = document.getElementById('image2');
img1.onmouseover = mouseOverImage1;
img2.onmouseover = mouseOverImage2;
Now when I start dragging image1 around, and I drag it over image2, the function mouseOverImage1 will get called. Very strange.
Even more curious, is that I've found out that by moving the focus away from the window, and then back onto it while I'm dragging an image, the event handlers begin firing as normal again. This is not a valid fix, but very odd behavior.
So I'm totally stumped. If anyone has any ideas, please help me out.
Thanks,
Adrian