-
Notifications
You must be signed in to change notification settings - Fork 273
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
Action is being triggered more than once #3
Comments
Actually, I partly solved it using |
@avishayil thanks for reporting -- are you on iOS or android? And was it only 'onRightActionComplete' that fired multiple times? Or the left side as well? |
Maybe i'm doing something wrong here (Ignore the Hebrew), and maybe it's the ListView that causes problems, notice the last part of the GIF: leftContent={(
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'flex-end', paddingRight: 20, backgroundColor: (this.state.leftActionActivated ? (!appStore.favoriteExists(story.id) ? '#00897b' : '#d32f2f') : '#ffab00') }}>
<View style={{ justifyContent: 'center', alignItems: 'center' }}>
<Icon name="add-to-favorites" style={{ color: '#ffffff' }} />
<Text style={{ color: '#ffffff' }}>{!appStore.favoriteExists(story.id) ? "הוסף למועדפים" : "הסר מהמועדפים"}</Text>
</View>
</View>
)}
onLeftActionActivate={() => this.setState({ leftActionActivated: true })}
onLeftActionDeactivate={() => this.setState({ leftActionActivated: false })}
leftActionActivationDistance={200}
onLeftActionRelease={() => {
!appStore.favoriteExists(story.id) ? appStore.add(story.id) : appStore.remove(story.id);
this.swipeable.recenter();
this.setState({ toggle: !this.state.toggle });
} } |
Hmm the The gif looks pretty choppy (maybe log statements?), so it's hard to tell what's going on. |
Hi, im having a similar issue even using onRightActionRelease. It seams to be that if a vertical scroll is made while swiping it triggers onRightActionRelease. I dont remember if native components for iOS when swiping allow to scroll vertically, but that seems to be the way to solve this. |
Interesting, @indesignlatam is there any way you can reproduce this with some sample code that I can run in my simulator? The |
Hi @jshanson7, im using the the List component of Native Base and the MeteorComplexListView of the react-native-meteor package. Is there something I should do to make it work? |
@indesignlatam @avishayil I figured out the problem -- you need to set <ScrollView scrollEnabled={!this.state.isSwiping}>
<Swipeable
onSwipeStart={() => this.setState({isSwiping: true})}
onSwipeRelease={() => this.setState({isSwiping: false})}
</Swipeable>
</ScrollView> See also: http://browniefed.com/blog/react-native-pan-responder-inside-of-a-scrollview/ |
Open to good ways to detect/prevent this within the Swipeable component. I'd prefer not to release a customized ScrollView/ListView and force people to use that. For the time being I will add a ScrollView example and make a note of this issue in the Readme. |
Great, I think adding this to the documentation is enough to start. I dont know of a way to set the parent props or state without a callback, if that is not possible the only thing that I can think of is a prop that returns the isSwiping state of the Swiper so that there is only 1 callback to pass as a prop. <ScrollView scrollEnabled={ !this.state.isSwiping }>
<Swipeable
onSwipe={ (isSwiping) => this.setState({ isSwiping }) }>
</Swipeable>
</ScrollView> |
Disable swipe prop
Hello, I encountered the same problem: my action is being triggered countless times when I swipe vertically while swiping horizontally. So I implemented @jshanson7's solution.
What could be done to solve these problems? |
I hate to say this, but I had to switch over to https://github.com/jemise111/react-native-swipe-list-view because of this issue. When I swipe diagonally, the actions were still triggered(and bad user experience...) I stopped trying to figure out the work around. Too much of headache... |
This is not fixed, I have tried with : <ScrollView scrollEnabled={!this.state.isSwiping}>
<Swipeable
onSwipeStart={() => this.setState({isSwiping: true})}
onSwipeRelease={() => this.setState({isSwiping: false})}
</Swipeable>
</ScrollView> after that, I am not able to scroll down on any of my devices. |
When playing swiping and swiping back while holding the swipeable action open, the action triggers countless times.
When swiping quickly, action triggers twice.
Also, this warning sometimes appear:
The text was updated successfully, but these errors were encountered: