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

[Web] Add onPointerOutOfBounds to LongPress gesture handler #3313

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

m-bert
Copy link
Contributor

@m-bert m-bert commented Jan 7, 2025

Description

As pointed out in #3310, LongPress on web does not override onPointerOutOfBounds method, which leads to gesture not being cancelled even if maxDistance was exceeded.

Fixes #3310

Test plan

Tested on the following code:
import React from 'react';
import { StyleSheet, View } from 'react-native';
import { Gesture, GestureDetector } from 'react-native-gesture-handler';

export default function EmptyExample() {
  const g = Gesture.LongPress()
    .onStart((e) => {
      console.log(e);
    })
    .onFinalize((e, s) => console.log(s))
    .shouldCancelWhenOutside(false);

  return (
    <View style={styles.container}>
      <GestureDetector gesture={g}>
        <View
          style={{
            width: 100,
            height: 100,
            backgroundColor: 'crimson',
          }}
        />
      </GestureDetector>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});

@m-bert m-bert merged commit 9620520 into main Jan 7, 2025
1 check passed
@m-bert m-bert deleted the @mbert/long-press-out-of-bounds branch January 7, 2025 13:52
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.

About LongPressGestureHandler and onPointerOutOfBounds (Web)
2 participants