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

Can't handle draggable element offsets with transform: translate #867

Open
sourav-mehra-lv opened this issue Dec 24, 2024 · 0 comments
Open

Comments

@sourav-mehra-lv
Copy link

sourav-mehra-lv commented Dec 24, 2024

Issue

The library seemingly can't handle draggable element offsets with transform: translate

I’ve run into an issue when adjusting the position of a draggable element. My use case is as follows:

  • I use transform: translate to visually adjust the position of the draggable element, making sure the start of the element is positioned under the cursor when the drag starts, no matter where the user drags it from.
  • While this visually updates the element’s position in the UI, the underlying drag logic continues to use the original position (before applying the transform styles), which causes a mismatch between the UI position and the droppable logic.

Is there a way to apply this offset to the underlying drag logic as well, so the logic uses the adjusted position, not the original one?

I’d appreciate any suggestions or guidance on how to handle this scenario.

What version of React are you using?

18.3.1

What version of @hello-pangea/dnd are you running?

16.6.0

What browser are you using?

Google Chrome (131.0.6778.205)

Demo

In the attached video, you'll see that once I start dragging the card, I adjust through CSS to be placed under the cursor. But when I drag it into the folders section, the droppable areas (greyed out folders) use the original position of the dragged element to calculate if the draggable file is over the droppable area (as seen when the greyed out folders become normal visually).

screen-recording-2024-12-23.mov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant