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.

Another example of Groups not following mouse on drag

See original GitHub issue

Environments

  • Moveable Component version: 0.42.0

Previous issues, that didn’t solve my issue:

In pretty much all of these issues, you suggest that the Moveable should have a rootContainer that has no transformations. If I set it to document.body it doesn’t fix the onDragGroup issue. I use #canvas as a selector - it has no transformations and is a parent of the <Rescaled /> container.

My setup:

  1. Canvas- a working area, that is scaled down with CSS’s transform.
  2. Boxes - Draggable elements within the Canvas. You can add boxes from the Add button, top right.
  3. Selecto - click or highlight area to select boxes. Selected boxes could be dragged.
  4. Guidelines - I dynamically create guidelines - the sides of the Canvas and the sides of the non-selected boxes. My guidelines are coordnates within the Canvas.

Reproduction sandbox:

https://codesandbox.io/s/elegant-northcutt-3jp4cj?file=/src/Editor.jsx

I’m sorry that my reproduction might not be exactly “minimal”, but I think it’s simple enough. The Editor.jsx is the important file.

Steps to reproduce:

  1. There are two boxes that are spawned by default, for the sake of the example.
  2. Click on a single box to select it. Now, you can drag it. It follows the mouse properly.
  3. Highlight two boxes with Selecto - drag and area with the mouse, or by holding down shift. Now, you have a group. Try dragging the group around.
  4. Bug: The group is being dragged a shorter distance than the mouse distance. The onDragGroup handler calls the exact same handler as onDrag.

Video

https://user-images.githubusercontent.com/19570004/201682663-a516960f-4842-4531-b106-72601c0581ed.mp4

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
xyj367commented, Nov 22, 2022

@joshmarnold

I have the same problem. After studying your codesandbox you provided, it is found that adding zoom={1 / store.scaleFactor} rootContainer={document.body} can solve the problem.

0reactions
joshmarnoldcommented, Nov 23, 2022

@xyj367 Thanks! This did appear to work. For posterity, I did the following:

  1. Set the zoom property on the Moveable component equal to 1/scale
  2. Set Selecto dragContainer equal to containerRef. conatinerRef is attached to container of boxes.

Note that I’m also using Selecto as well which adds complexity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding Success Criterion 2.5.7: Dragging Movements
Some people cannot perform dragging movements in a precise manner. Others use a specialized or adapted input device such as a head pointer,...
Read more >
Drag and Drop Mouse Bug - Not sure If related to windows 7 ...
An example: Select a group of files to move. Begin a right click drag to the new destination. Midway through dragging a right...
Read more >
Row Dragging - JavaScript Data Grid
When you drag an item that is not selected while other items are selected, only the unselected item will be dragged. Example: Row...
Read more >
Drag'n'Drop with mouse events - The Modern JavaScript Tutorial
The problem is that, while we're dragging, the draggable element is always above other elements. And mouse events only happen on the top...
Read more >
Draggable SVG elements - Peter Collingridge
The click-and-drag interaction has two obvious parts: click and drag, but really there are three: Pressing the mouse, when we need to find...
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