Question regarding the collision detection #1355
Unanswered
JohannesW-DE
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, i've implemented a custom sortable list which allows for nested groups.
The simplified structure, which is stored in a state, looks like this:
DndContext
List (droppable)
-> List of ( Item (sortable) | Group (sortable) )
with:
Group
-> List of ( Item (sortable) )
I've implemented a custom collision detection algorithm as well, but i've encountered a problem. Currently i need the representing rectangle of every droppable for my onDragMove handler to move the items around as needed. So everything i do is based around the premise that i have access to those rectangles via the collisions property of the DragMoveEvent.
If i have a simple list and move around the items everything works fine, with the rectangles being updated as soon as i move around two items and update the state. but if i try to shuffle around items inside a group, everything feels wonky. I've narrowed it down to the fact that the rectangles are not updated when the state hosting the list data is updated.
I'm stuck figuring out the difference what's the difference for those cases, since i figured everytime a draggable changes it's position the collisions are updated. The algorithm works fine, the collisions that it's receiving are "stale" for the case of moving items inside a group.
Hoping for ideas, thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions