Closed abtx closed 6 years ago
Sure.. there is always a way :) In dragularenter
event listener, access dragularService.shared.source
. It is an container element where the item was dragged from, you can also check dragularService.shared.target
All the properties of the shared object are commented in source at the top of the file: https://github.com/luckylooke/dragular/blob/master/src/dragularService.js
You may find useful other properties too.. I did not documented it because I wanted to handle it another way, but since I have stopped the development of this library for now, it is hardly to be changed in foreseeable future.
Thanks @luckylooke, dragularService.shared.source
returns the container though, but sourceItem
does the trick! Excellent, thanks for a quick reply!!
I've created a tree with Dragular, which now I want to use so that when I drag an element over a node I can drop it on that node as a child element. I tried to look for properties when using
dragularleave
anddragulardrop
: I use a unique ID for each node withe.target.getAttribute('id')
so I know what I'm hovering over. Now I need to know what is the unique ID of the actual element I drag so that I don't trigger a function that will expand child elements of a node on the dragged node. Right now when I move an element, the first 'target' is the very same node I drag, so I need to find a way to eliminate it as a real target on hover over. If I had the source ID I can say something likedon't fire expandChildNodes() if the target has the same ID as the source
. Is there a way to access the source's ID attribute like that? Thanks!