bevacqua / dragula

:ok_hand: Drag and drop so simple it hurts
https://bevacqua.github.io/dragula/
MIT License
22.01k stars 1.97k forks source link

Cannot use "over" function to set "accepts" return value #535

Closed miragecraft closed 6 years ago

miragecraft commented 6 years ago

I want to do some checking in the "accepts" option on container level only (I don't care about siblings).

However this means that the "accepts" function rapidfires needlessly while within the container, and it is making my dragging action jerky.

I want to move the checking into the "over" call, however I've encountered two issues.

There is no clear order of which function fires first - "accepts" or "over", there seems to be a racing condition here. This means if I put the checking function in "over" there will be a flash of the shadow before the container is found to be invalid.

Secondly when "accepts" returns false, "over" function doesn't trigger. This means that I have to have that flash of shadow, else the "over" function wouldn't fire.

miragecraft commented 6 years ago

Found a workaround, I used the drake.on('drag') function to change the containers list to only containers that satisfy my conditions so the function only fires once per drag operation, I used drake.on('drop') to reset the container list after the drag operation is complete.