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

Capture swipe gesture only on the card instead of the container? #6

Closed
lsps9150414 opened this issue May 7, 2017 · 1 comment
Closed

Comments

@lsps9150414
Copy link

lsps9150414 commented May 7, 2017

Detects swipe gesture only on the card makes it usable in apps that support swipe to nav to left/right tabs.

@alexbrillant
Copy link
Owner

alexbrillant commented May 7, 2017

The swipe gesture is only captured with the cards. However, you made me realize that I shouldn't render the cards AnimatedView when all the cards have been swiped. I was setting the content to null....
I will close the issue when v1.1.2 is pushed.
Thanks for pointing that out!

Old code :

renderFirstCard = () => {
    const { firstCardIndex } = this.state
    const { cards } = this.props
    const swipableCardStyle = this.calculateSwipableCardStyle()
    const firstCardContent = cards[firstCardIndex]
    let firstCard = this.props.renderCard(firstCardContent)
    const notInfinite = !this.props.infinite
    if (notInfinite && this.state.swipedAllCards) {
      firstCard = null
    }
    return (
      <Animated.View
        style={swipableCardStyle}
        {...this._panResponder.panHandlers}>
        {firstCard}
      </Animated.View>
    )
}

New code :

renderFirstCard = () => {
    const { firstCardIndex } = this.state
    const { cards } = this.props
    const swipableCardStyle = this.calculateSwipableCardStyle()
    const firstCardContent = cards[firstCardIndex]
    let firstCard = this.props.renderCard(firstCardContent)
    const notInfinite = !this.props.infinite
    if (notInfinite && this.state.swipedAllCards) {
      return null
    }
    return (
      <Animated.View
        style={swipableCardStyle}
        {...this._panResponder.panHandlers}>
        {firstCard}
      </Animated.View>
    )
}

alexbrillant pushed a commit that referenced this issue Jul 27, 2017
alexbrillant pushed a commit that referenced this issue Nov 14, 2017
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

No branches or pull requests

2 participants