Closed hnrq closed 2 years ago
I used to update the state (e.g.: items list array) when drag:stop
or drag:stopped
and then draggable elements re-rendered because the state changed. The above approach doesn't need to prevent or cancel any event, but it is not performant because all draggable elements are re-rendered after sorted.
I used to update the state (e.g.: items list array) when
drag:stop
ordrag:stopped
and then draggable elements re-rendered because the state changed. The above approach doesn't need to prevent or cancel any event, but it is not performant because all draggable elements are re-rendered after sorted.
I'm trying to do something similar, but I'm currently getting two instances of the same item into the list (Probably happens because Solid does not re-render the container, but only appends a new instance). It would be really good if preventing the new node from being appended were possible.
I also think it's good to prevent manipulate DOM, but no one has merged PR and released a new version recently for this project. There is another idea I found in react-sortablejs that revert nodes to pre-drag position then change React state.
Good idea! I might try and take a look into the lib, however, looks like there are lots of PRs waiting to be merged and no updates on master for a long time :/. That's a bummer, I might as well give dragula a try, seems like it has a similar API
Okay, I gave up on Dragula because it is too slow on mobile. I'll figure out how to make that event cancellable
For support questions, please use stackoverflow. This repository's issues are reserved for feature requests and bug reports.
1. Apply either the
bug
orfeature-request
labelbug
: Can't select one on the right sidebar, don't know why.2. Describe the
bug
orfeature
Hey guys, I'm trying to build a drag and drop that's controlled by state management using
shopify/draggable
andSolid.js
. Here's what I thought: Addingdata-id
attributes to the containers, intercepting a sortable event, cancelling it and dispatching the move action. This would all work as expected, except that I can't preventsortable:stop
from adding the item as a children to the new container. Is there a way to do that? Also, is this the right approach? I think that I could also just let Draggable handle the DOM changes and keep the state in sync with them, but I'm not sure if that's the right thing to do as well. Any help appreciatedPlease remember that with sample code it's easier to reproduce the bug and it's much faster to fix it.
4. Please tell us about your environment: