-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
best way to handle arbitrary grouping? #569
Comments
let me see if i understood: |
that's helpful, is it possible to reorder the list by dragging items or only to group them while maintaining the original order? |
Yes, items should still be sortable. This would work similar to how the crazy nesting example works from the docs (in this example, i can drag item 5 all the way to the base level, or i can drag it into the node 3 or node 4 group. For my use case, if each item has it's own dnd zone, there's 3 situations that together create the behavior im looking for. 1. Sorting at the base level Keep in mind that for each imagine, the entire thing is a dnd zone as well (in addition to each item's dnd zone). 2. Dragging an item into a group 3. Dragging an item out of a group Of course, sorting items within a group is trivial and shouldn't require any data conversion. Does this sound reasonable? If possible, I would love some help with the implementation. It's not totally clear to me how to deal with the pruning of empty dnd zones and the wrapping of items inside new dnd zones. If you can think of a simpler way of accomplishing this, i'd love to hear it! |
I see, so the basic structure is:
|
oh i hadn't even thought of that! As far as i can tell, that should handle everything as long as the "in between" zones are recomputed after every finalize (after re-ordering, dragging an item into a group, and out of a group). Would you be able to create a bare minimum REPL for this? I think it might be a useful example to include in the docs. |
I agree it would be a useful example. I can't promise I'll get to it this
week (there are two issues i need to look into first)
…On Tue, May 7, 2024 at 11:11 AM aaron-barbieriaghib < ***@***.***> wrote:
oh i hadn't even thought of that! As far as i can tell, that should handle
everything as long as the "in between" zones are recomputed after every
finalize (after re-ordering, dragging an item into a group, and out of a
group).
Would you be able to create a bare minimum REPL for this? I think it might
be a useful example to include in the docs.
picture to make sure we're on the same page:
image.png (view on web)
<https://github.com/isaacHagoel/svelte-dnd-action/assets/8888888/c5761750-5466-41e7-b28e-a9867b285c53>
—
Reply to this email directly, view it on GitHub
<#569 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE4OZCZB3WWTD7KRC454BN3ZBAS4XAVCNFSM6AAAAABHIIH2PWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJXGE4DCOJTGE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I made a simple version of what you described, but it's quite jittery and difficult to use. I'd probably need to implement a rule that disallows dragging an item into the empty zone directly above or below it (to prevent useless layout shifts), but even then, im not sure it would ever be as smooth as a solution that makes use of an outter dnd zone. Any ideas?
|
Hi, |
yeah this is already so much better than what i had! I'll take a look at the bug in the next few days and report back |
ok I looked into it, and the issue is that the readjust function assumes that whenever an item leaves behind an empty zone (because it's dragged somewhere else), it's sandwiched by 2 other empty zones – the one right before it and the one right after. This is correct, unless you drag the item into the empty zone right below it, in which case the here's a version of the repl that solves this issue, and also disables directly adjacent in-between zones if the group length is one. this is definitely getting closer. Happy to help with other improvements if you're looking to include this example in the docs btw! |
@quangthandev Cool. Thanks for this. What do you feel is still missing in order for this to "be there"? |
I'm honestly quite happy with this. The only minor thing I would mention are the layout shifts thanks for all the help throughout this btw, super appreciate it :) |
I'm looking for a way to be able to drag an element into another one to create a group. Im not looking for infinite nesting, just a single layer. The main issue im running into is that when i drag an element out of a group and back into the base layer, i need to wrap that element in a dnd zone (so that i can drag other elements into it to create a new group). Conversely, when i drag a base level element into an existing group, i need to be careful to prune the empty dnd zone that i've "left behind" (this is much easier).
I'm struggling to come up with a way of representing the data such that it won't require conversion on drag, since all the zones have the same type. Would really love some help with this!
The text was updated successfully, but these errors were encountered: