-
Notifications
You must be signed in to change notification settings - Fork 109
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
Transitions not working in combination with drag and drop #96
Comments
Hi, When you add transition |
Thanks so much for your fast reply and your help! I'm going to check this out and play with it for a bit, it looks very useful. I did notice I can break it by clicking the add button twice in quick succession, but that's probably something that can be fixed. Does svelte-dnd-action actually remove the item from the list while it's being dragged? |
Hi, Technically speaking, svelte-dnd-action does not remove items from the list, your Two more thoughts:
|
Thanks for the clarification about what svelte-dnd-action does exactly. This is how I thought it would work, but the behaviour with transitions confused me. Since svelte-dnd-action does not actually remove items from the list, and my My use case (which answers your thought 2) is a list that the user can add items to, using an input field, and remove items from, using a delete button, and sort by drag and drop. Items will not enter or leave the list through drag and drop. Am I correct in assuming that the transition should not be triggered in this case? I agree completely that items fading in and out during drag operations would be very weird, since the user is "holding" the item while dragging. |
Thanks to digging in this I did find a bug in the library/ svelte (#101) though it is not what's causing the incompatibility with To your question, open the console in this REPL. Notice that the handler is fired on drag start and removes the dragged element from the list of items. |
Hi, thanks so much for the time you're spending on this issue. 🙂 The library is really useful and I'm not trying to nitpick, but I do think this is something that can be improved and I'm willing to help out if I can! I believe that removing the item from the list on drag start (which basically assumes that every item that is dragged will leave the territory) is not entirely correct. It causes unintentional state changes even when not using transitions. One example that illustrates this clearly is when dragging the last item of a list: I first made your REPL work correctly again by removing the transition. Then, when you start to drag Yoda (the last item in the list), you can see that the dropzone actually becomes smaller. This doesn't happen when dragging any of the other items. When letting go of Yoda on its original position, it actually is outside of the dropzone. Because of this, svelte-dnd-action reverts all changes and replaces the original list. This does provide the intended behaviour but it feels to me like this is sort of by accident. It would be nice if the dropzone would only change size after the item is actually dragged away from the original list. This may also solve the transition problem. I tried to solve this naively by removing the splice from row 317, but this just broke everything. 😅 I think I'm missing some other moving parts when removing just this line. svelte-dnd-action/src/action.js Lines 316 to 318 in e9c871a
I would like to tinker around a bit to see if I can make this work, but I'm also curious about your thoughts. |
Hi, The item is removed from the list when drag starts and then adds itself to the list it is over if any (which may or may not be the original list (depending on the layout of the page, the drag speed etc). Even if it won't be removed it still needs to be replaced with the shadow item (placeholder) which might be immediately removed if the item is not over the list. In other words, the same number of mutations or more. Svelte's built in fade out will not play nice no matter what as far as I can tell. I am willing to be convinced otherwise on any of the points and if you'd like to experiment you're more than welcome. |
Hello 👋 I seem to be running into a similar issue, replicated in this REPL. It seems that a fade out causes the same breakage if nested anywhere inside the element being dragged (this example is only 1 level deep, but I have seen the same issue nested 4 levels in). |
Hi @kyythane |
Unfortunately I haven't had time to look into this yet. Transitions and animations can play well together. Take a look at this REPL. Type something in the input and press enter. It uses both a transition and an animation when adding an item. But as I said, unfortunately I haven't had the time yet to investigate how to make that work with this library as well, if that is at all possible. |
@EmielH it gets hairy when state changes are involved. I was referring mainly to this: |
This is what blocks using crossfade, right? |
So I just ran into this issue when trying to use crossfade, and have been experimenting w/ the suggested workarounds in the svelte REPL. Problem is, unlike the fade transitions, I can't seem to get the workaround to... work. I'm just gonna leave this here: REPL, and resort to removing the crossfade transition. My REPL showcases the neccessity of the crossfade transition, which is that non-drag-n-drop changes to the data can be pretty jarring without crossfade. |
Any workaround for crossfade in the last 2+ years, or is it just not compatible with this library? There is a small note about transitions in the documentation, but IMO (since I just spent 90 minutes figuring out the issue) a more explicit callout is warranted. My use-case: Imagine a kanban board that updates live as other users make changes. Not very understandable without crossfade. |
Out transition during drag are where the problem is.
…On Wed, Feb 5, 2025, 12:00 Reilly Moore ***@***.***> wrote:
Any workaround for crossfade in the last 2+ years, or is it just not
compatible with this library? There is a small note about transitions in
the documentation, but IMO (since I just spent 90 minutes figuring out the
issue) a more explicit callout is warranted.
My use-case: Imagine a kanban board that updates live as other users make
changes. Not very understandable without crossfade.
—
Reply to this email directly, view it on GitHub
<#96 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE4OZC6OUO5SQFHHSDABZY32OFPERAVCNFSM6AAAAABWP3W562VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMZVGQ3TCMBVGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I was able to wrap both the in and out ( let boardOrigin: 'local' | 'remote' = 'remote';
const conditionalSend = (node: any, params: CrossfadeParams & { key: any }): () => TransitionConfig => {
if (boardOrigin === 'remote') {
return send(node, params);
}
return () => { return {} };
}; There are still 2 remaining issues I can see to deal with
Edit: Actually the second issue isn't really related to transitions. I'll see if this topic of updating the data source mid-drag has been discussed elsewhere. Thanks |
When you have a draggable list that has transitions, as soon as you drag an item, it is removed from the list. You can still drag it around, but it's impossible to get it back into the list. I'd like to have transitions for adding items to and deleting items from the draggable list.
How to reproduce
Go to the Svelte REPL and enter the following code:
(Code based on this article.)
See that the item disappears from the list as soon as you start dragging and that it is impossible to put it back in the list.
When starting to drag, this error appears in the console:
(The error is from my personal project, not from the REPL, because the REPL console doesn't show the source files and line numbers as clearly.)
When you remove
transition:fade
from the item div, everything is working perfectly again.My (totally uneducated) guess is that the transition removes the element from the DOM, while svelte-dnd-action does not know about this. Could this be the case? Is it possible to make this work?
The text was updated successfully, but these errors were encountered: