-
-
Notifications
You must be signed in to change notification settings - Fork 329
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: When dropping aligned to a grid, it does not drop where it should #453
Comments
Experiencing the same issue. Thanks for posting. |
My temporary workaround for this issue is to use the example: onDragStop(event, data) {
this.setState({
x: data.lastX
y: data.lastY
})
} This leads me to believe the issue is isolated to the |
Any updates on this issue? I have re-created with a potential workaround by @kpettinga but no luck unfortunately https://codesandbox.io/s/4l310zyzw7 |
Found a fix for anyone looking. I just commented out //position={{ x: this.state.x, y: this.state.y }} |
Facing the issue as well. x and y returned from onDragStop is not what it should be according to the snapGrid array setting. |
Just checked the issue seems to be in the source library (react-draggable). I created an issue for this: react-grid-layout/react-draggable#413 |
I had the same problem It was necessary to move and resize the element Using this combination of properties and methods, the necessary behavior was achieved
|
I had the same problem. And @pebbledesigns, that isn't a solution (that's just making the component uncontrolled... it won't help with us folks who need to control the position). |
This was caused by `onStop` erroneously recalculating coordinates, which is not necessary / should not happen in the real world, as `mouseup` and `touchend` should not pass `clientX` and `clientY` values meaningfully different than the last corresponding move event. In fact, they are already ignored by `<Draggable>`. For this reason, we can simply trust the `lastX` and `lastY` in `onDragStop`, and pass those back. Fixes #413, bokuweb/react-rnd#453
I would consider this a bug.
Overview of the problem
The dragGrid is honored when dragging the object, but when it is dropped it "jumps" when ending the drag. You can see it in the example if you release the drag carefully so you don't move when releasing it and you can watch it jump when you let it go. It is now impossible to drag it back on top of the second item that was never moved, because they are now locked to different 50 x 50 grids (in this case).
Reproduced project
The following CodeSandbox demonstrates the issue:
https://codesandbox.io/s/pyyj7l55mx
Description
This is a modified clone of the size/position example. There are two rectangles that start on top of eachother, and each has a dragGrid and resizeGrid of [50, 50].
Steps to Reproduce
Expected behavior
I expected them to drop exactly as a they appeared before release and honoring the dragGrid to keep them on the grid.
Actual behavior
They don't drop where you drop them, and they move off the grid, causing them to have their own grid that is not aligned with other objects using a dragGrid
The text was updated successfully, but these errors were encountered: