Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change absolute position to be relative to the window instead of the screen #1812

Conversation

j-piasecki
Copy link
Member

Description

This PR changes how absolute position of events is calculated to be relative to the window instead of the screen. This makes it consistent with iOS and takes status bar and split-screen mode into account when calculating it.

Test plan

Tested on the Example app

@j-piasecki j-piasecki merged commit a96694d into software-mansion:main Jan 10, 2022
@j-piasecki j-piasecki deleted the absolute-position-relative-to-window branch January 10, 2022 09:51
j-piasecki added a commit that referenced this pull request Mar 26, 2024
…roid (#2826)

## Description

In
#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:
- It used
[getWindowVisibleDisplayFrame](https://developer.android.com/reference/android/view/View#getWindowVisibleDisplayFrame(android.graphics.Rect))
which `tells you the available area where content can be placed and
remain visible to users`. This was always taking status bar height into
account, even if the app could be drawn behind it.
- It was calling this method on the `decorView`, which is drawn under
system bars anyway

This PR changes it to use `contentView` of the current activity and
[getLocationOnScreen](https://developer.android.com/reference/android/view/View#getLocationOnScreen(int[]))
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants