1.0.0 • Published 6 years ago

react-native-scrollable-container v1.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

react-native-scrollable-container

基于React Native官方组件ScrollView与React-Navigation实现headerTitle与界面的滑动的交互效果

Installation

npm install react-native-scrollable-container --save

Import into your project

import ScrollContainer from 'react-native-scrollable-container';

Examle useage

static navigationOptions = ({ navigation }) => ({
  ...ThemeStyles.indexHeaderStyle,
  headerTitleStyle: {
    ...ThemeStyles.indexHeaderStyle.headerTitleStyle,
    opacity: navigation.getParam('opacity', new Animated.Value(0)),
  },
  headerTitle: navigation.getParam('title', ''),
});
<ScrollContainer title="个人中心" navigation={this.props.navigation} scrollOffset={this.state.scrollOffset}>
  <Header
    onLayout={(e) => { this.setState({ scrollOffset: e.nativeEvent.layout.height - px2dp(18) }) }}
    title="个人中心"
    iconName="cog"
    onPress={() => this.props.navigation.navigate('settings')}
  />
  {this.renderUserInfo()}
  {this.renderOptions()}
</ScrollContainer>

Properties

属性描述类型默认
title导航栏标题PropTypes.string.isRequired标题
scrollOffset滑动距离阀值PropTypes.number.isRequired0
style样式PropTypes.oneOfType([ PropTypes.object, PropTypes.number ]){ flex: 1, backgroundColor: '#F7F7F7' }
navigation导航属性PropTypes.object.isRequired必填,否则无法控制导航,实现交互效果