react-rnd icon indicating copy to clipboard operation
react-rnd copied to clipboard

Bug: Component change the Y position when Drag stops even though dragging is restricted to X axis

Open chathuraa opened this issue 6 years ago • 4 comments

Overview of the problem

I'm using react-rnd version [9.0.2]
My browser is: Chrome Version 69.0.3497.100

I am sure this issue is not a duplicate?

Reproduced project

https://codesandbox.io/s/j1vj3j90ov

Description

Bug: Component change the Y position when Drag stops even though dragging is restricted to X axis

Steps to Reproduce

  1. Restrict the dragAxis to x
  2. Drag the component vertically
  3. Release the mouse button

Expected behavior

Since the dragging is restricted to X there shouldnt be any changes to the y position of the component

Actual behavior

the y position of the component changes

chathuraa avatar Oct 02 '18 15:10 chathuraa

I may have fixed the issue, though not sure if this the the best way to do so.

let draggablePosition;
    if (position) {
      draggablePosition = {
        x: position.x - left,
        y: position.y - top,
      };
      if (dragAxis === "x") {
        draggablePosition = {
          x: position.x - left,
          y: position.y,
        };
      }
      if (dragAxis === "y") {
        draggablePosition = {
          x: position.x,
          y: position.y - top,
        };
      }
    }

chathuraa avatar Oct 02 '18 16:10 chathuraa

@chathuraa Thanks for your report and reproduced project :) I'll do some investigation. Thanks 👍

bokuweb avatar Oct 03 '18 02:10 bokuweb

Hey @bokuweb, This is my first Pull request ever... sorry if I haven't done it properly.

chathuraa avatar Oct 03 '18 11:10 chathuraa

Hasn't this bug been fixed? Two years later, dragAxis still does not work!?!

mididev avatar Jan 09 '21 19:01 mididev