With two nested elements in dropzone
and dragging from outer to inner element, dragleave
actions take precedence over dragenter
.
I have initially one div as dropzone
, which on dragenter changes class ('canDrop') to indicate if drop is possible, while on dragleave the class reverts to neutral ('plainDropZone').
On drop the draggable
div becomes a child of the dropzone
div. Now, when another draggable
enters the dropzone
, class is changed to 'noDrop' to indicate no more drops are possible. On dragleave
the class reverts to neutral again ('plainDropZone')
The Problem: When dragging from outer dropzone
div to the inner dropped div, the outer dropzone
div should not revert to neutral, but still have the class 'noDrop'.
As far as I have found out this does not work as intended, because when moving from outer to inner div, dragleave
gets fired after dragenter
. This thread visualizes the problem nicely: HTML 5 drag events: 'dragleave' fired after 'dragenter'
Here is a full demo: https://jsfiddle.net/e12uadgh/
So what would be a way to assign the outer dropzone
div the class 'noDrop', when it has a dropped inner div and the user drags a third div from outer dropzone
div to inner dropped div?