AirLabsTeam / react-drag-to-select

A react library which adds drag to select to your app
https://airlabsteam.github.io/react-drag-to-select
MIT License
157 stars 22 forks source link

onSelectionChange gets MouseEvent of the starting click #4

Closed PhatNguyen213 closed 3 years ago

PhatNguyen213 commented 3 years ago

Currently the onSelectionChange only receives one parameter which is the selection box.

However while selecting I need to do some calculations based on the clientX and clientY of the starting click. The starting click may not always be the top left as you can drag from bottom to top, for example.

Is there any ways I can get this information?

moises-marquez commented 3 years ago

The selection box is comprised of top, left, width and height. Based on them you should be able to calculate the starting click coordinates (i.e, left - width if your element is on the right side of the horizontal plane).

dwilt commented 3 years ago

@PhatNguyen213 going to close this per @moises-marquez's comment as that should suffice for your needs.