question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Drag multiple objects at once

See original GitHub issue

Hi, 
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: dragAndDropMultiple 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:open
  • Created 3 years ago
  • Reactions:4
  • Comments:6

github_iconTop GitHub Comments

2reactions
moklickcommented, Feb 21, 2021

We implemented this exact use case in our react-flow library. It looks something like this:

  1. wrap all draggable elements with DraggableCore (you always need to store all positions of your elements and pass it to the DraggableCore wrapper)
  2. append the onDrag handler for all elements (and remember which ones are selected and their positions)
  3. when the user drags an element you can use data.deltaX and data.deltaY of the onDrag handler and add it to all positions of the selected elements

Hope it helps 😃

0reactions
STRMLcommented, Feb 21, 2021

Use DraggableCore and manage the state yourself.

On Sun, Feb 21, 2021 at 4:50 AM amoghadami notifications@github.com wrote:

anyone found a solution for this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/STRML/react-draggable/issues/474#issuecomment-782829603, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJEKP3WSLE5NBUFDZ47UVDTADJQDANCNFSM4MQ7KF2A .

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Move Multiple Objects in Illustrator
Click on the "Selection" tool in the Adobe Illustrator toolbox. Click on the first object you want to move. Hold down the "Shift"...
Read more >
How to select and move multiple objects - Miro Help Center
If you work with a keyboard, you can also select particular objects by clicking them one by one while holding down Shift or...
Read more >
How to drag multiple objects at once in React? - Stack Overflow
Here are my experiments with react-draggable: codepen.io/markvital/pen/gOaRMNX. Multiple objects can be selected, but only one is draggable.
Read more >
Drag multiple objects at once · Issue #474 · react-grid ... - GitHub
Hi, Is it possible to drag multiple draggable instances at once? I'm using draggable to manipulate geometric shapes. The objects are in ...
Read more >
Drag multiple object using multitouch? - Unity Answers
Your next issue might be your startPos variable. You only have a single startPos variable. If you want to be able to drag...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found