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

onTouchesMove reports invalid absolute position values during pinch gesture #3073

Closed
Glazzes opened this issue Aug 27, 2024 · 4 comments · Fixed by #3078
Closed

onTouchesMove reports invalid absolute position values during pinch gesture #3073

Glazzes opened this issue Aug 27, 2024 · 4 comments · Fixed by #3078
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided

Comments

@Glazzes
Copy link

Glazzes commented Aug 27, 2024

Description

Hi there and thank you all for your open source efforts, I'm currently creating a zoomable image component and in order to achieve this behavior I need the absolute position (absoluteX and absoluteY values) of both fingers on the screen, however I'm getting the following issues.

  • If the element to pinch is NOT scaled, the values reported by onTouchesDown and onTouchesMove for both pointers are all correct.

  • if the element to pinch is scaled, the values reported by onTouchesDown and onTouchesMove are all incorrect, for some reason one of the pointers is able to report the correct value for the x axis.

    Some other things to note about this problem, if both fingers are moved in the same horizontal direction both pointers will report valid values on the x axis.

    If you keep one finger stand still at the screen and start moving the other, you will be able to see the values reported for the stand still finger will start to increase.

I can not tell whether this problem happens on iOS as I don't own an Apple device.

Steps to reproduce

  • comment the line with the onUpdate callback
  • pinch the orange view and look at the console, the values are correct relative to the screen.
  • reload the dev server
  • uncomment the line with the onUpdate callback
  • pinch the orange view and look at the console, the values reported are NOT correct relative to the screen.

Snack or a link to a repository

https://snack.expo.dev/@glazzes/d545df

Gesture Handler version

2.16.1

React Native version

0.74.1

Platforms

Android

JavaScript runtime

Hermes

Workflow

Expo managed workflow

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

Real device

Device model

Alcatel 5044R (Android 7)

Acknowledgements

Yes

@github-actions github-actions bot added Repro provided A reproduction with a snack or repo is provided Platform: Android This issue is specific to Android labels Aug 27, 2024
@Glazzes
Copy link
Author

Glazzes commented Aug 29, 2024

I'd like to add something to this issue after some testing from my part, scaling the item affects the values reported as already mentioned however modifying width and height properties reports correct values.

@coado
Copy link
Contributor

coado commented Aug 30, 2024

I'd like to add something to this issue after some testing from my part, scaling the item affects the values reported as already mentioned however modifying width and height properties reports correct values.

Hey, thanks for your report. I've pushed the code that should fix the issue.

@Glazzes
Copy link
Author

Glazzes commented Aug 31, 2024

@coado Thank you for your work, I wonder, was this an Android only issue? As I mentioned I don't have an iPhone.

@coado
Copy link
Contributor

coado commented Sep 2, 2024

@coado Thank you for your work, I wonder, was this an Android only issue? As I mentioned I don't have an iPhone.

Yes, that was something specific to android implementation. The iOS handles that out of the box.

@j-piasecki j-piasecki linked a pull request Sep 2, 2024 that will close this issue
j-piasecki pushed a commit that referenced this issue Sep 2, 2024
## Description

The PR fixes the issue mentioned
[here](#3073)
about the incorrect absolute positions on touch events. The view
transformations should not affect the absolute position of the touch, so
the source event should also be passed to gesture handlers and used for
calculations. It applies to `ACTION_DOWN`, `ACTION_MOVE`, and
`ACTION_UP` motion events.

<!--
Description and motivation for this PR.

Include 'Fixes #<number>' if this is fixing some issue.
-->

## Test plan

I've checked on android device for repro provided in the above-mentioned
issue with some scroll offset.

<!--
Describe how did you test this change here.
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants