Open getnashty opened 8 years ago
+1 I also need this - e.g. by setting props on the swiper scrollEnabled: {true}
Hey @d-krueger, @getnashty
The Swiper
component bypasses the props to the ScrollView
so you can set the scrollEnabled={false}
whenever you want to.
quick and dirty sample:
class Sample extends Component {
state = {
disableScroll: false
}
render() {
const itemStyle = { flex: 1, justifyContent: 'center', alignItems: 'center' }
return (
<Swiper scrollEnabled={!this.state.disableScroll}>
<View style={[itemStyle, { backgroundColor: 'gray' } ]}>
<Text>View 1</Text>
<TouchableOpacity
style={{ backgroundColor: 'cyan' }}
onPressIn={() => this.setState({ disableScroll : true })}
onPressOut={() => this.setState({ disableScroll : false })}
>
<Text>DO NOT SCROLL</Text>
</TouchableOpacity>
</View>
<View style={[ itemStyle, { backgroundColor: 'yellow' } ]}>
<Text>View 2</Text>
</View>
</Swiper>
)
}
}
Is it possible to temporarily lock the swiper functionality while a panresponder is receiving touch events inside the swiper component?