Skip to content
This repository was archived by the owner on Sep 16, 2020. It is now read-only.

Scrolling

Roy Shen edited this page May 12, 2017 · 4 revisions

Detect scrolling to prevent accidental swipeouts

Set an initial boolean state for scrolling

getInitialState: function() {
  return {
    scrollEnabled: true
  }
}

Create a function to change scroll state

_allowScroll: function(scrollEnabled) {
  this.setState({ scrollEnabled: scrollEnabled })
},

Connect scrollEnabled prop to scroll state

scrollEnabled can be set for ScrollView or ListView and will disable scroll when set to false. Swipeout scroll returns false when swiping horizontally and true when swiping vertically.

<ScrollView scrollEnabled={this.state.scrollEnabled}...>
 <Swipeout scroll={event => this._allowScroll(event)}>...</Swipeout>
<ScrollView/>
Clone this wiki locally