Skip to content

Conversation

@brentvatne
Copy link
Contributor

@brentvatne brentvatne commented Aug 2, 2017

No need to use this exact implementation, it was quick to just get a proof of concept working. It does seem like a valuable prop to add, however. I was able to implement SwipeActions like this:

render() {
  const translateX = this.state._translateX;

  return (
    <View>
      <PanGestureHandler
        id={this.props.gestureId}
        minDeltaX={50}
        maxDeltaY={5}
        onGestureEvent={this._onGestureEvent}
        onHandlerStateChange={this._onHandlerStateChange}>
        <Animated.View
          style={{ transform: [{ translateX: translateX }] }}
          onLayout={this._onLayoutChildren}>
          {this.props.children}
        </Animated.View>
      </PanGestureHandler>

      {this._renderButtons()}
    </View>
  );
}

And on the parent ScrollView I wait for the pan gestures to fail.

|| !isnan(_minOffsetX) || !isnan(_minOffsetY)
|| !isnan(_minVelocityX) || !isnan(_minVelocityY) || !isnan(_minVelocitySq);
|| !isnan(_minVelocityX) || !isnan(_minVelocityY) || !isnan(_minVelocitySq)
|| !isnan(_maxDeltaY);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think setting "max" bounds shouldn't affect _hasCustomCriteria as when you for example only set "max" but no min, then gesture will never fire. The purpose of _hasCustomCriteria was so that we can use platform default settings of UIPanGestureHandler if no other criteria are set, but the way it works is that if some "min" constrains are set we have a custom logic that is responsible for testing if handler should activate. So if there are no "min" props set and hasCustomCriteria is true the gesture will never activate.

{
// NOTE(brent): Probably there is a better place to update this cached value, didn't
// think too much about it.
_hasCustomCriteria = [self hasCustomCriteria];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go in the configure step of gesture handler subclass

@kmagiera
Copy link
Member

kmagiera commented Aug 3, 2017

There are few small things that require fixing but I want to get this in so will fix this on my own. ty

@kmagiera kmagiera merged commit 9a0494d into software-mansion:master Aug 3, 2017
osdnk pushed a commit that referenced this pull request Aug 7, 2019
Adds UNSAFE_ prefix for deprecated lifecycle hooks. (For more information about this codemod, see [React RFC #6](reactjs/rfcs#6))
janicduplessis pushed a commit to janicduplessis/react-native-gesture-handler that referenced this pull request Feb 16, 2020
Adds UNSAFE_ prefix for deprecated lifecycle hooks. (For more information about this codemod, see [React RFC software-mansion#6](reactjs/rfcs#6))
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.

2 participants