ObaidUrRehman / ng-drag-drop

Drag & Drop for Angular - based on HTML5 with no external dependencies. :tada:
MIT License
239 stars 123 forks source link

Class drag-border doesn't disappear on fast drag and drop #115

Open dleric opened 6 years ago

dleric commented 6 years ago
Oowaay commented 6 years ago

Any news about this bug ? I got the same problem with nested drag / drop container .

image

In my case, I think it happen when I drop an item inside a drop container who is inside another drop container. Borders of the container where I drop the item are removed, but borders are not removed of the parent who include the other drop container.

On the screen I've dropped item "testp" on item "testeg" so testeg and testtes borders hint has shown , but whe, I've drop the item, only the testeg borders was removed.

Hope it will help to find the bug

vmsoftware commented 6 years ago

I have found a solution, however I don't know if it is the best aproach... however It works

I hope this help to any person in the future.

simply at the end of OnDrop function put:

var items = document.querySelectorAll(".drag-over-border");

for (let j = 0; j < items.length; j++) { items[j].classList.remove("drag-over-border"); }

This symply search for elements with that class and remove it.

krishghosh commented 6 years ago

Any updates on this bug? I have noticed that intermittently onDragEnd is not triggered and it that time when the dragClass and dragHintClass remain applied to concerned items.

krishghosh commented 6 years ago

Alright, this might be helpful for anybody who is facing this issue too. For me, the actual problem lies in my project itself and not the ng-drag-drop module.

What caused my issue was: I had a background task running, that in every few seconds updated the dom. Now this process momentarily block page (few milliseconds). Problem is that during this dom update, drag events are ignored. So for me if during that update process, dragend was triggered, it is never captured and hence ng-drag-drop is not even notified that the drag has ended, resulting in the drag and drop hint classes still being applied.

I fixed that part in my code and it works smooth.

So, make sure any such process is not scheduled in your application, which is causing the events to be lost. This doesn't seem to me as an issue with this library.