Skip to content

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

Open

Description

@gabrielmfern

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.

Activity

  1. LostKobrakai commented on May 23, 2024

    @LostKobrakai

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

    const [state, _] = useDragDropContext();
    
    let mousePos = () => state.active.sensor?.coordinates.current;
  2. gabrielmfern commented on May 23, 2024

    @gabrielmfern
    Author

    @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.

  3. LostKobrakai commented on May 23, 2024

    @LostKobrakai

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions