Drag multiple objects at once
See original GitHub issueHi, Is it possible to drag multiple draggable instances at once? I’m using draggable to manipulate geometric shapes. The objects are in different positions in DOM model, so I can not wrap them in one <Draggable>…</Draggable> instance.
Here is an example of what I want to achieve:
When I drag the rectangle, rounded square or triangle, all 3 should move at the same time.
I have to maintain the order in which the objects overlap while dragging (so I can’t wrap all of them into one element).
It would be great to have some sort of draggableGroup
attribute to assign to different draggable components. Or some way to exchange information between different draggable elements.
I know such a possibility exists in react-dnd, but it’s a much complicated framework to use for me.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:6
We implemented this exact use case in our react-flow library. It looks something like this:
onDrag
handler for all elements (and remember which ones are selected and their positions)data.deltaX
anddata.deltaY
of theonDrag
handler and add it to all positions of the selected elementsHope it helps 😃
Use DraggableCore and manage the state yourself.
On Sun, Feb 21, 2021 at 4:50 AM amoghadami notifications@github.com wrote: