LongPressGestureHandler event payload inconsistent between ios/android
See original GitHub issueI’m trying to implement hold-and-drag interaction like this: user long press on an element, dragger appears under user’s finger if long press active, then user could start moving the dragger by moving fingers.
Code below works fine on iOS, but not on Android. It turns out that the event payload is different for ios and android (android event payload didn’t provide x
, y
, absoluteX
, absoluteY
, etc). Not sure if this is the expected behavior.
How to implement this interaction if there’s no absoluteX
to use?
handleLongPressGestureEvent = (o) => {
console.log(o.nativeEvent); // move the element by o.nativeEvent.absoluteX
}
render() {
return (
<LongPressGestureHandler
onGestureEvent={this.handleLongPressGestureEvent}
>
<View style={{height: 200, width: 200, backgroundColor: 'green'}} />
</LongPressGestureHandler>
);
}
Event payload for ios
absoluteX: 137.5;
absoluteY: 335.5;
handlerTag: 1;
numberOfPointers: 1;
state: 4;
target: 4;
x: 50;
y: 102;
Event payload for android
handlerTag
:
1
numberOfPointers
:
1
state
:
4
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Common handler properties | React Native Gesture Handler
E.g. event payload for PinchGestureHandler contains scale attribute that represents how the distance between fingers changed since when the gesture started.
Read more >Declarative API exposing platform native touch and gesture ...
I'm encountering an issue when using the RefreshControl component exported from react-native-gesture-handler. I have a FlatList that renders a ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Please be patient. There’s one PR related (adding proper payload’s field) and I believe it is going to be merged soon
Done 😃