svelte-dnd-action
svelte-dnd-action copied to clipboard
How to detect when an item is moved because of another item.
Hi! I'm making a treeview and I need items to automatically open when they are hovered over or moved
Normally such logic would go into the "consider" handler. If u have a concrete example i might be able to provide a better answer
On Thu, Feb 3, 2022, 09:52 Zachiah @.***> wrote:
Hi! I'm making a treeview and I need items to automatically open when they are hovered over or moved
— Reply to this email directly, view it on GitHub https://github.com/isaacHagoel/svelte-dnd-action/issues/349, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE4OZC2QEBUNH65K6M54TM3UZGYR5ANCNFSM5NNLE3YA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hi! I have an example with solid-dnd-directive
I figure the answer would apply to both so that's why I made the issue here though.
https://codesandbox.io/s/adoring-shaw-somoc?file=/src/main.tsx
so if i expand the top level and then drag child 1 over child 2 what should happen? should child 2 not move but expand instead?
Ideally it would expand if it was less than half way over, and move when it's more than half way over, but just getting it to expand at all is the hard part
@isaacHagoel
sorry. logic that is based on the direction from which the element entered is going to be problematic. something that could work: when the element hovers over (== trying to change the index of) an expandable it gets detected in the consider handler, it should stay in place (set the items to themselves instead of e.detail.items), expand if collapsed, and the consider handler that's inside should notify the parent when either the item is dropped inside or when the item left (one of the triggers of consider is DRAGGED_LEFT). when the parent gets notified on either it should start allowing it's items to get re-sorted as normal (=== it stops insistings on items = [...items] and goes back to items=e.detail.items). i hope it is not to hand wavy.