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

Allowing access to mouse position on drag & drop context's events #106

Open
gabrielmfern opened this issue Feb 7, 2024 · 3 comments
Open

Comments

@gabrielmfern
Copy link

I really needed a way to get the displacement of the mouse's position, without hacks preferably,
on every onDragMove which, thinking from a perspective of a outsider to the code base here, could
be trivial as it probably already uses some mouse event under the hood, the idea would be to just
expose all of the data about the event, maybe through a different property that comes into the onDrag----
listeners.

@LostKobrakai
Copy link

Seems like you can use the following (even outside the callback)

const [state, _] = useDragDropContext();

let mousePos = () => state.active.sensor?.coordinates.current;

@gabrielmfern
Copy link
Author

gabrielmfern commented May 23, 2024

@LostKobrakai Interesting, thanks for letting me know!

Do you know how the active sensor works btw? I'm not sure what it is, like, are there multiple sensors or is it a single one, is it an event listener under the hood — not sure.

@LostKobrakai
Copy link

By my understanding the sensor is what watches out for drags to start and stop. The default one is pointer based, but seems like you could implement drag and drop controlled by different means by switching out the sensor implementation.

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

2 participants