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

iOS Swiping last page triggers click #698

Open
yuoppp opened this issue Dec 19, 2017 · 4 comments
Open

iOS Swiping last page triggers click #698

yuoppp opened this issue Dec 19, 2017 · 4 comments

Comments

@yuoppp
Copy link

yuoppp commented Dec 19, 2017

Which OS ?

iOS

Version

Which versions are you using:

  • react-native-swiper v1.5.13
  • react-native v0.45.0

Expected behaviour

When I try to swipe first page to the left or last page to the right, I expect to see scroll borders.

Actual behaviour

Instead of displaying scroll border, the onClick action is triggered

Steps to reproduce

  1. create swiper with 2+ pages. the page itself should contain touchable* element
  2. set loop={false}
  3. swipe first page to the left or last page to the right.
  4. catch the touchable* onPress event
@zhuweicz
Copy link

any progress about this issue?

@arslansajid
Copy link

Looks like this issue has not been resolved yet.

@aarondulpina
Copy link

aarondulpina commented Feb 24, 2020

Managed to prevent catching the onPress by:
<View onMoveShouldSetResponderCapture={()=>true}> <TouchableOpacity onPress={()=>console.log('Pressed')}>//render something</TouchableOpacity> </View>

@ghost
Copy link

ghost commented Apr 15, 2021

A hacky way to do this - Differentiate tap and swipe by checking tap locationX. If same location, tap. Different location, swipe. Feel free to adjust the +-5 threshold

let onPressX = 0 // Put this variable outside

<TouchableOpacity
  onPressIn={(e) => {
    onPressX = e.nativeEvent.locationX;
  }}
  onPressOut={(e) => {
    if (
      e.nativeEvent.locationX > onPressX - 5 &&
      e.nativeEvent.locationX < onPressX + 5
    ) {
      this.callYourAction()
    }
  }}
>

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

4 participants