react-rnd
react-rnd copied to clipboard
Bug: Component change the Y position when Drag stops even though dragging is restricted to X axis
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
- Restrict the dragAxis to x
- Drag the component vertically
- 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
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 Thanks for your report and reproduced project :) I'll do some investigation. Thanks 👍
Hey @bokuweb, This is my first Pull request ever... sorry if I haven't done it properly.
Hasn't this bug been fixed? Two years later, dragAxis still does not work!?!