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.13k stars 982 forks source link

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

Closed j-piasecki closed 8 months ago

j-piasecki commented 8 months 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 8 months ago

Also you can add that it fixes #2816