Last edit: I've found this question. It looks to be a Chrome issue.
I'm trying to drag a jQuery UI draggable element over an element which on CSS :hover
bring up (z-index
based) some of its childrens. I need that those childrens to accept my dragging object (they are all jQuery UI droppable).
Here is the jsFiddle.
How it should work: drag a blue circle on the left element to another circle on the right element. Draggable element is turning in a red one, and all droppable elements must bring on top and become green bordered. Same behavior is expected if we drag a circle from right element to the left one.
After each drop
event, draggable and droppable elements involved become heavy bordered, as a visual feedback of the user action.
However, I've tested this one in the following browsers, each of them have some issues:
- Chrome 43.0.2357.124 m - the CSS
:hover
state isn't triggered, but droppable elements accept the draggable one.activeClass
andhoverClass
from droppable element refuse to work, and the CSS:hover
have the same issue. - Firefox 38.0.5 - the CSS
:hover
state is triggered only if I usecursorAt
option in draggable element.activeClass
andhoverClass
from droppable element also works fine. Problem in Firefox is that droppabledrop
event isn't fired (or I reffer the element itself wrong). - Internet Explorer 11.0.20 - nothing works, it fires some errors in the console (Access is denied, 'jQuery' is undefined, '$' is undefined).
For almost one and a half day I try to figure out if this a jQuery glitch, a browser problem, or is anything wrong with my code. And of course to find a cross browser solution for this problem.
Thanks for your time and your interest!
Edit: updated jsFiddle link.
The solution for Internet Explorer is quite simple. You are using an outdated version of jQuery. You're using version 1.10.1, but the current supported version is 2.1.3. Switching to a newer version should solve problems in modern browsers.
As for why the hover effect isn't working, the CSS hover event doesn't seem to be triggered while the mouse is down unless it was originally hovered over that specific element. To make this work regardless of whether the mouse is pressed, JavaScript would be more reliable to detect the hover event instead of CSS.
For example, trying pressing the mouse down originally from outside of the divs, constantly holding it down while moving inside them. Notice how the CSS
:hover
is not triggered while JavaScript is.