svelte-dnd-action icon indicating copy to clipboard operation
svelte-dnd-action copied to clipboard

Use the library as a mere (where it started) -> (where it ended) tracker?

Open paoloricciuti opened this issue 1 year ago • 8 comments

Hi, i have to implement drag and drop for a file tree and i would love to use this library. However i'm in a bit of trouble because i'm already keeping my svelte store in sync with a virtual file system inside a webcontainer and i can't really let the library mutate the array because i would then need to resync everything with the webcontainer and there are occasions when i would need to do the opposite.

Now i don't realy care about the (ammittedly supercool) feature of previewing the moved node in the new list so i would love to just use the library as a way to visualize the "grabbing" of the node and to have a starting point and an ending point. Is there a way to do it?

paoloricciuti avatar Apr 11 '23 09:04 paoloricciuti

I would like to know if and how this would be possible as well. There may be a workaround involving hiding the temporary elements and analyzing the before and after item list, but this seems way to complicated.

McCrafterIV avatar Dec 10 '23 13:12 McCrafterIV

I missed the original issue somehow. Sorry about that. It's hard to answer without seeing an example (or having a much more formal definition) of what you are trying to achieve

On Mon, Dec 11, 2023, 00:29 McCrafterIV @.***> wrote:

I would like to know if and how this would be possible as well. There may be a workaround involving hiding the temporary elements and analyzing the before and after item list, but this seems way to complicated.

— Reply to this email directly, view it on GitHub https://github.com/isaacHagoel/svelte-dnd-action/issues/443#issuecomment-1848966185, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE4OZC4I5HDTXBTB7RPRN7LYIW2NNAVCNFSM6AAAAAAWZ7MZSWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBYHE3DMMJYGU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

isaacHagoel avatar Dec 10 '23 20:12 isaacHagoel

emember

I don't have an example to show but the idea is basically to start grabbing (I get a start event with the "entry" that has been grabber) the drag is handled just like it is today without the preview effect and when you drop you get another event with (if possible) the starting entry and the ending entry so that I can do the mutation of the array myself

paoloricciuti avatar Dec 10 '23 20:12 paoloricciuti

Imagine you have a file picker you want to implement. Every file should be draggable and droppable in other folders. But if you press shift, you want to be able to select a series of files by just dragging over them. Here it would be useful to be able to track where the user started dragging and where they stopped dragging. For this use-case we don't need to animated the dragging of the initial element, as we don't want to drag that to another place but rather use the bare dragging information to implement a custom behavior.

McCrafterIV avatar Dec 11 '23 09:12 McCrafterIV

While it is possible to use this library for multi drag, I think I get your point. In this case I would recommend using another library or the browser's built in drag and drop API. This library was designed with the common use case in mind and aspires to make that super easy by not requiring its users to think about the internals.

On Mon, Dec 11, 2023, 20:24 McCrafterIV @.***> wrote:

Imagine you have a file picker you want to implement. Every file should be draggable and droppable in other folders. But if you press shift, you want to be able to select a series of files by just dragging over them. Here it would be useful to be able to track where the user started dragging and where they stopped dragging. For this use-case we don't need to animated the dragging of the initial element, as we don't want to drag that to another place but rather use the bare dragging information to implement a custom behavior.

— Reply to this email directly, view it on GitHub https://github.com/isaacHagoel/svelte-dnd-action/issues/443#issuecomment-1849636460, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE4OZC5OO3KH6MMW5BDSKQ3YI3GLZAVCNFSM6AAAAAAWZ7MZSWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBZGYZTMNBWGA . You are receiving this because you commented.Message ID: @.***>

isaacHagoel avatar Dec 11 '23 09:12 isaacHagoel

From my research, there are not many other good dnd libraries out there. I don't think this should be a thing the user has to configure but rather an option that can be used. You said this is possible using your library. Could you provide a small code sample to show how to detect start and end of a drag in relation to the drop zone / item position it started and ended?

McCrafterIV avatar Dec 23 '23 08:12 McCrafterIV

The multi drag example i was referring to is one of the examples in the README If you need a specific example please provided a clear definition of the behaviour you are after in some structured format (e.g bullet points)

isaacHagoel avatar Dec 23 '23 21:12 isaacHagoel

might be helpful... https://svelte.dev/repl/4d0d5c59848f4c0eb061dfcbd89c1c41?version=4.2.8

mikeatquvee avatar Dec 26 '23 13:12 mikeatquvee