Question

I wonder if there is a 'OnDragLeave' event or something like that? OnDragOver fires when dragged element 'hits' an element, i want an event that fires when the dragged element leaves this other element. Thanks in advance

Was it helpful?

Solution

I've googled everything there is and haven't found any event that could help me.

So i'm marking(giving 0,5 opacity) the element that the dragged element is over using OnDragOver, and saving the element in global so the next time OnDragOver fires i can 'unmark' it. This will raise some issues because it will not fire if dragged element gets dragged out from the element over to svg, so the 'marked' element is still marked, but should not be, still it was the only possible solution.

On up event for dragging, i'm moving my element to its start position and using document.elementFromPoint(event.clientX, event.clientY)(you can then move the dropped element back if you want) to get the element that my dragged element was dropped on(check ids so it's not the same element, can happen if element dropped back on it's place).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top