software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
6.14k stars 982 forks source link

Unify scaled coordinates between `web` and `native` side. #2943

Closed m-bert closed 5 months ago

m-bert commented 5 months ago

Description

On android and iOS if you scale view and get relative coords, they will act like they were not scaled at all. Let's say that we have a square with size 100x100. If you click in the middle, x and y fields in event will both be 50. Now, if you scale this view by 2 (i.e. new size is 200x200) and click in the middle, you'll still get values of 50.

Web takes scale into account and on the above situation, second output would be 100. To unify this behavior we now divide coords by scale factors.

Test plan

Add console.log(e.x, e.y) in any example with scale, for example in transformations

m-bert commented 5 months ago

@j-piasecki Probably we do, I've missed that so thanks for reminding me. Also, I think it will be better to do it in other PR, I hope you don't mind.