react-native-swipeable icon indicating copy to clipboard operation
react-native-swipeable copied to clipboard

Swiping laggy in ios when setting state to prevent multiple activations

Open Vaintti opened this issue 7 years ago • 5 comments

Swiping is laggy on ios when I set state on onSwipeStart and onSwipeRelease

Vaintti avatar Jun 30 '17 10:06 Vaintti

I think onSwipeRelease triggering before it should has something to do with this. I use the component as listView row.

Vaintti avatar Jul 03 '17 14:07 Vaintti

@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

jshanson7 avatar Jul 08 '17 19:07 jshanson7

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 avatar Aug 08 '17 12:08 Jagadeesh-Govindaraj

@Jagadeesh-Govindaraj thank you so much, that is a great fix for the lag.

rxb avatar Sep 13 '17 14:09 rxb

@Jagadeesh-Govindaraj best method ever!

glebselyukov avatar Nov 16 '17 10:11 glebselyukov