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
5.83k stars 952 forks source link

Use correct origin point for calculating the absolute position on Android #2826

Closed j-piasecki closed 1 month ago

j-piasecki commented 1 month ago

Description

In https://github.com/software-mansion/react-native-gesture-handler/pull/1812 I changed how absolute position is calculated to be relative to the window instead of the screen, but there were two things wrong with it:

This PR changes it to use contentView of the current activity and getLocationOnScreen which gets the coordinates of this view in the coordinate space of the device screen, irrespective of system decorations and whether the system is in multi-window mode.

In a nutshell, after this PR the absolute position will take into account whether the app is displayed behind the status bar.

Test plan

Tested on the example app:

https://github.com/software-mansion/react-native-gesture-handler/assets/21055725/c3230a2d-7bba-483b-b160-1c9fb32b0da1

https://github.com/software-mansion/react-native-gesture-handler/assets/21055725/701d9fa0-0c9f-4126-af58-f80c6a0a6526

m-bert commented 1 month ago

Also you can add that it fixes #2816