You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working on something that's similar to Vertical Multi-containers.
Issue: When working with containers of same height there is definitely no issue. However, when working with containers whose heights are highly different it might look confusing for the user. Please notice how the collision detection works when you drag the item back to its previous location. Visually, there is no collision between the item item being dragged and its upper neighbor. And yet, a collision is detected :
NOK-transform.mp4
The reason why it behaves like that is due to the way rectangles are measured. In my case I need them to take the transform into account (which is not the case by default). To do that we should use the method getClientRect.
Using the following code did not really help as it only measures the rectangles before and right after the dragging starts : measuring={{ droppable: { strategy: MeasuringStrategy.Always, measure: getClientRect, }, etc
Rectangles of droppable containers are not re-measured after collisions, I guess this is by design.
I've also been playing a lot with the measureDroppableContainers method in useEffect, also in conjunction with requestAnimationFrame since it should be performed once the transition has been applied to the droppable containers. I didn't get it to work :(
Workaround: I've made it to trigger the measuring of the droppable containers (droppableRects actually) by updating my state in onDragOver. Now it looks accurate to me, but it has the drawback of mutating the DOM any time I found a relevant collision :
OK-mutation.mp4
Looking for a better solution: A significant point of using the sortable preset is to avoid those DOM mutations and this is exactly what I would like to achieve. I am not sure if any of you guys have already been thinking about that? I would welcome any idea :)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
First off, thank you for this amazing library!
I'm currently working on something that's similar to Vertical Multi-containers.
NOK-transform.mp4
The reason why it behaves like that is due to the way rectangles are measured. In my case I need them to take the transform into account (which is not the case by default). To do that we should use the method
getClientRect
.Using the following code did not really help as it only measures the rectangles before and right after the dragging starts :
measuring={{ droppable: { strategy: MeasuringStrategy.Always, measure: getClientRect, }, etc
Rectangles of droppable containers are not re-measured after collisions, I guess this is by design.
I've also been playing a lot with the
measureDroppableContainers
method in useEffect, also in conjunction withrequestAnimationFrame
since it should be performed once the transition has been applied to the droppable containers. I didn't get it to work :(OK-mutation.mp4
Thanks for your help
Beta Was this translation helpful? Give feedback.
All reactions