Skip to content

Conversation

@eeynard
Copy link
Contributor

@eeynard eeynard commented Sep 30, 2020

Description

This PR fixes a bug in isWithinBounds making GestureHandler hitSlop top not usable.

Test Plan

Create a new view with a PanGestureHandler and shrink the hitSlop to only the top part of the view. Events should not be sent when gesture are made outside de red area.

Before : Events were fired in the white and red area
After : Events are fired only on the red area as expected

import React from 'react';

import { StyleSheet, View } from 'react-native';
import { PanGestureHandler } from 'react-native-gesture-handler';

const HEADER_HEIGHT = 200;

const BottomSheet = () => (
  <PanGestureHandler
    onGestureEvent={() => console.log('Gesture handled')}
    hitSlop={{ top: 0, height: HEADER_HEIGHT }}>
    <View style={styles.container}>
      <View style={styles.activeZone} />
    </View>
  </PanGestureHandler>
);

export default BottomSheet;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: 'white',
  },
  activeZone: {
    backgroundColor: 'red',
    height: HEADER_HEIGHT,
  },
});

@jgonet
Copy link
Member

jgonet commented Sep 30, 2020

Thanks for the PR.

Could you please post some code you tested this change on?

@eeynard
Copy link
Contributor Author

eeynard commented Sep 30, 2020

@jakub-gonet I updated the description :)

@eeynard
Copy link
Contributor Author

eeynard commented Oct 2, 2020

@jakub-gonet Is there any chances this could be added in the next release ? I am really looking forward this bug fix. Thanks !

@jgonet
Copy link
Member

jgonet commented Oct 2, 2020

Yeah, probably. I'll dedicate more time to the gesture handler in the next week, so I'll test and merge it. You can use patch-package until then.

@jkadamczyk jkadamczyk self-assigned this Oct 5, 2020
@jkadamczyk jkadamczyk self-requested a review October 5, 2020 09:03
@jkadamczyk
Copy link
Contributor

Hey @eeynard I copied and pasted your example to expo managed app. Even though it was using the release version of gesture handler it worked like you described in the expected behaviour without your changes.
Would you mind updating the example or recreating it in expo or sharing a project that makes it possible to easily reproduce it?
Thanks for the PR, and have a good day!

@eeynard
Copy link
Contributor Author

eeynard commented Oct 5, 2020

Hey @jkadamczyk, you're right, my example does not seems to be relevant. I made another one on snack, here is the link https://snack.expo.io/TGAF2FyWn. Hopefully this time you can reproduce the problem.

I'll edit the PR description as well. Thank you !

Note: On the snack example the counter increments on every events received by RN-gesture-handler. You can see that it does not do anything on the red zone like it should but events are sent when you play with the bottom of the screen.

@jkadamczyk
Copy link
Contributor

Thank you!!!
I'll take a look tomorrow!

@jkadamczyk
Copy link
Contributor

@eeynard Tested it works as it should.
Merci beaucoup!

@jkadamczyk jkadamczyk merged commit e6f1164 into software-mansion:master Oct 7, 2020
braincore pushed a commit to braincore/react-native-gesture-handler that referenced this pull request Mar 4, 2021
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.

3 participants