Created
October 31, 2017 13:55
-
-
Save ashrithks/8d97f928d92643468a26e29c4d2dbb67 to your computer and use it in GitHub Desktop.
nestedScrollview in react native
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { View, ScrollView } from 'react-native'; | |
export default class App extends Component { | |
constructor() { | |
super(); | |
this.state = { | |
enabled:true | |
}; | |
} | |
render() { | |
return ( | |
<ScrollView | |
scrollEnabled={this.state.enabled} | |
> | |
<View style={{height:600,backgroundColor:'violet'}}></View> | |
<View style={{ height: 2000, backgroundColor: 'red' }} > | |
<ScrollView | |
onTouchStart={(ev) => { | |
this.setState({enabled:false }); }} | |
onMomentumScrollEnd={(e) => { this.setState({ enabled:true }); }} | |
onScrollEndDrag={(e) => { this.setState({ enabled:true }); }} | |
style={{ margin: 10, maxHeight: 200 }} > | |
<View style={{ height: 200, backgroundColor: 'blue' }} /> | |
<View style={{ height: 200, backgroundColor: 'pink' }} /> | |
<View style={{ height: 200, backgroundColor: 'blue' }} /> | |
<View style={{ height: 200, backgroundColor: 'pink' }} /> | |
<View style={{ height: 200, backgroundColor: 'blue' }} /> | |
<View style={{ height: 200, backgroundColor: 'pink' }} /> | |
<View style={{ height: 200, backgroundColor: 'blue' }} /> | |
<View style={{ height: 200, backgroundColor: 'pink' }} /> | |
<View style={{ height: 200, backgroundColor: 'blue' }} /> | |
<View style={{ height: 200, backgroundColor: 'pink' }} /> | |
<View style={{ height: 200, backgroundColor: 'blue' }} /> | |
<View style={{ height: 200, backgroundColor: 'pink' }} /> | |
</ScrollView> | |
</View> | |
</ScrollView> | |
); | |
} | |
} | |
+1
Has anyone found how to handle this?
Hello, please is there a chance to scroll content of app using buttons ? I have 2 buttons, up and down. How can i make it slowly scroll up or down ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@andresmechali
This only works if you click on the ScrollView. If you are normally scrolling then this method is not getting called.