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

Make it work in zoomed context #32

Open jamesyu opened 1 year ago

jamesyu commented 1 year ago

I'm using this in a "infinite" div which allows zooming using css transfrom scale property. When scaled, the position of the box is in correct because it is positioning based on non-zoomed coordinates. Is there a way to compensate for this?

I could calculate the new coordinates manually on selection change, but I don't know how I can use that to influence the box on selection start. Any tips?

dwilt commented 1 year ago

@jamesyu sorry for the late reply. we definitely haven't accounted for this sort of solution. if you come up with something, would you mind sharing with us so we could considering putting it into the package if we think it's appropriate?

sascharissling commented 1 year ago

I think an option to pass a zoomfactor (e.g. 1.2, 2.0, 3.0) that would move the selection box back to the tip of the cursor, or any other any way to manipulate where the box spawns on the screen would be beneficial.

dwilt commented 1 year ago

@sascharissling would you be willing to contribute a PR? It's outside the scope of what we need this plugin for but would be happy to accept a PR!