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

Possible to support for swipe up/down? #16

Open
niravj-spaceo opened this issue Sep 7, 2021 · 3 comments
Open

Possible to support for swipe up/down? #16

niravj-spaceo opened this issue Sep 7, 2021 · 3 comments

Comments

@niravj-spaceo
Copy link

Will it be possible to support for swiping up/down?

@JungHsuan
Copy link
Owner

Yes, it's possible, but it would have conflicts if your content is scrollable.

@niravj-spaceo
Copy link
Author

@JungHsuan
So, what I have currently is a app in landscap mode and have side scrolling content.
I have implemented up/down direction with react-native-card-flip package. It works but not looks good like what your have in this pacakge.
I would like to implement the same with this package. Any tweaks that you can make or suggest to support this?

@JungHsuan
Copy link
Owner

Sorry, there might be no simple tweaks.

  1. You should also listen to the event of dy in onPanResponderMove
return Animated.event([{ dx: this.state.scrollX, dy: this.state.scrollY }],
    { useNativeDriver: false })(gestureState);
  1. To rotate component by scrollY, adding rotateX in your transform props of Animated.View:
rotateX: scrollY.interpolate({
    extrapolate: 'clamp',
    inputRange: [-height, 0, height],
    outputRange: Platform.select({
        ios: ['-180deg', '0deg', '180deg'],
        android: ['180deg', '0deg', '-180deg'],
    }),
}),
  1. Since we would also set the face of card by scrollY, so we should add a listener for scrollY, too.
this.state.scrollX.addListener(({ value }) => {
 // here we do the same thing as we do for scrollX, but the you should 
 // use height instead of width to check the boundary
 // e.g.
 // const endRight = start + this.state.width;  -> should use height 
 // const endLeft = start - this.state.width;     -> should use height
}
  1. Maybe you don't want to rotate the card on both X and Y direction at the same time, because it would be skewed. Therefore, checking dx and dy of current gesture in onMoveShouldSetPanResponder should help you decide which direction to rotate.

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