react-native-swipeable
react-native-swipeable copied to clipboard
Swiping laggy in ios when setting state to prevent multiple activations
Swiping is laggy on ios when I set state on onSwipeStart and onSwipeRelease
I think onSwipeRelease triggering before it should has something to do with this. I use the component as listView row.
@Vaintti do you think this could be the same issue as #3? The current fix is to set scrollEnabled
to false
when a row is being swiped. See also https://github.com/jshanson7/react-native-swipeable#common-issues
Here is my working solution.(this.setState() is make to swipe slower so prefer local variables in your swipe actions)
_disableScroll() {
//debugger;
this._list.getScrollResponder().setNativeProps({
scrollEnabled: false
})
}
_enableScroll() {
this._list.getScrollResponder().setNativeProps({
scrollEnabled: true
})
}
swipeView
<Swipeable
onSwipeStart={this._disableScroll.bind(this)}
onSwipeRelease={this._enableScroll.bind(this)}>
</Swipeable>
ListView
<ListView ref={ref => this._list = ref} />
@Jagadeesh-Govindaraj thank you so much, that is a great fix for the lag.
@Jagadeesh-Govindaraj best method ever!