Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chathuraa opened this issue Oct 2, 2018 · 4 comments

Comments

@chathuraa
Copy link

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
Copy link
Author

chathuraa commented Oct 2, 2018

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,
        };
      }
    }

@bokuweb bokuweb added the bug label Oct 3, 2018
@bokuweb
Copy link
Owner

bokuweb commented Oct 3, 2018

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

chathuraa added a commit to chathuraa/react-rnd that referenced this issue Oct 3, 2018
Component change the Y / X position when Drag stops even though dragging is restricted to X/Y axis
@chathuraa
Copy link
Author

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

chathuraa added a commit to chathuraa/react-rnd that referenced this issue Oct 4, 2018
chathuraa added a commit to chathuraa/react-rnd that referenced this issue Oct 4, 2018
chathuraa added a commit to chathuraa/react-rnd that referenced this issue Oct 5, 2018
Added a story for axis restriction
chathuraa added a commit to chathuraa/react-rnd that referenced this issue Oct 6, 2018
@mididev
Copy link

mididev commented Jan 9, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants