Skip to content

How to get the position of the mouse using the graph coordinate system? #1176

@sztanko

Description

@sztanko

Thank you for your amazing library.

I am implementing a custom tree layout and drag & drop functionality for the graph layout and I would like to get the position of mouse in terms the graph coordinate system for onMouseMove event (so I can determine the closest graph tree branch where the draggable element should potentially belong to)
Because of zoom and translate, event.clientX - ref.current.getBoundingClientRect().x wouldn't really work here.

Could you please advise on what would be the easiest way of retrieving those coordinates?

Thanks,

D.

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