react-native-scrolltotop 回到顶部-组件 (ios/android)
2017-03-08 23:09
633 查看
react-native-scrolltotop
https://github.com/yzsolo/react-native-scrolltotopa RN component make list come back to top.
IOS
&& ANDROID
---
Installation
npm install --save react-native-scrolltotop
Usage
example
see the example/example.js for a more detailed example.import ScrollTopView from 'react-native-scrolltotop'; //first set default state in your constructor constructor(props) { //... this.state = { isShowToTop: false, }; } //then bind a method to detect the scroll distance of your listView //set ref with 'listview' <ListView ref="listview" onScroll={(e)=>this._onScroll(e)} style={styles.listView} renderScrollComponent={(props)=>{ return <ScrollView style={styles.ViewPort} {...props}/> }}/> //here is the _onScrol method _onScroll(e) { var offsetY = e.nativeEvent.contentOffset.y; if(offsetY > 100) { this.setState({ isShowToTop: true }) } else { this.setState({ isShowToTop: false }) } } //use it with your listView together <View style={{flex:1}}> <View style={styles.header}> <Text style={styles.headerText}>消息列表</Text> </View> {listView} {this.state.isShowToTop?<ScrollTopView root={this} ></ScrollTopView>:null} </View>
相关文章推荐
- android-scrollToTop回到顶部-兼容PullTorefreshScrollview
- Android scrollToTop实现点击回到顶部(兼容PullTorefreshScrollview)
- 关于Android PullTorefreshScrollview回到顶部实例
- 好用的ReactNative下拉刷新上拉加载的组件,支持iOS和Android
- react-native-smart-barcode目前最好用的二维码扫描组件(IOS、android)
- React-Native实现ListView组件之上拉刷新实例(iOS和Android通用)
- 《React-Native系列》组件封装之Dialog(iOS和Android通用)
- react-native-smart-barcode目前最好用的二维码扫描组件(IOS、android)
- 支持android&ios高度自适应及JS相互调用的组件react-native-webview2
- JQuery回到顶部(Scroll to Top)
- React Native之Image组件使用时Android和iOS兼容性
- 关于Android PullTorefreshScrollview回到顶部实例
- 《React-Native系列》19、 ListView组件之上拉刷新(iOS和Android通用)
- 《React-Native系列》13、 组件封装之Dialog(iOS和Android通用)
- react-native-easy-toast, 一款简单易用的 Toast 组件,支持 Android&iOS.
- react-native-easy-toast, 一款简单易用的 Toast 组件,支持 Android&iOS.
- react-native-easy-toast, 一款简单易用的 Toast 组件,支持 Android&iOS.
- 关于Android PullTorefreshScrollview回到顶部实例
- Android PullTorefreshScrollview回到顶部
- 支持android&ios高度自适应及JS相互调用的组件react-native-webview2