facebook / react-native

A framework for building native applications using React

Home Page:https://reactnative.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LocationX, locationY behaves differently on Android vs iOS

Sharcoux opened this issue · comments

Please provide all the information requested. Issues that do not follow this format are likely to stall.

Description

On Android, GestureEvent location seem to be relative to the View the event is currently above, and not the component the listener is attached to. On iOS it is the opposite.

Note that the web implementation seems to follow the iOS behavior.

React Native version:

Run react-native info in your terminal and copy the results here.

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. Create a View with a padding of 100
  2. Within this view, create a View with onMoveShouldSetResponder={() => true} and listen onResponderMove={event => console.log(event.nativeEvent.locationX)}
  3. Move through the inner View vertically.

Expected Results

The value of locationX should not change when crossing the inner View vertically

Actual Results

When outside the inner View, the location of the event is relative to the outer View. The event is changing its reference. This is probably not the expected behavior because:

  1. iOS works as expected
  2. react-native-web works as expected
  3. Working with an event that can change of referential mid-way would be very troublesome for devs.

Snack, code example, screenshot, or link to a repository:

Snack reproducing the problem

commented

same issue

I'm also encountering the same problem.

I think that the error resides within this file. The x and y coordinates should be translated from the target of the touch event to the target of the event listener.

Can confirm this issue still exists...