question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LongPressGestureHandler event payload inconsistent between ios/android

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
osdnkcommented, Aug 25, 2018

Please be patient. There’s one PR related (adding proper payload’s field) and I believe it is going to be merged soon

1reaction
osdnkcommented, Sep 20, 2018

Done 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found