Skip to content

Commit

Permalink
Added containerStyle for outermost <View>
Browse files Browse the repository at this point in the history
- Added `scrollViewProps`
- Added `scrollViewStyle`
- Renamed original `containerStyle` to `innerContainerStyle`
  • Loading branch information
kyaroru committed Feb 8, 2019
1 parent 3651c76 commit 90a3ec7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,13 @@ render() {
backgroundImageScale={1.2}
renderNavBar={this.renderNavBar}
renderContent={this.renderContent}
contentContainerStyle={{ flexGrow: 1 }}
containerStyle={{ flex: 1 }}
contentContainerStyle={{ flexGrow: 1 }}
innerContainerStyle={{ flex: 1 }}
scrollViewProps={{
onScrollBeginDrag: () => console.log('onScrollBeginDrag'),
onScrollEndDrag: () => console.log('onScrollEndDrag'),
}}
/>
</View>
);
Expand All @@ -113,7 +118,10 @@ render() {
| `title` | `any` | No | This is the title to be display in the header, can be string or component | Default to `null` |
| `titleStyle` | `style` | No | This is the title style to override default font size/color | Default to `color: ‘white’ `text and `fontSize: 16` |
| `scrollEventThrottle` | `number` | No | This is the scroll event throttle | Default is `16` |
| `contentContainerStyle` | `style` | No | This is the contentContainerStyle style to override default `<ScrollView>` contentContainerStyle style | Default to `null` |
| `contentStyle` | `style` | No | This is the inner content style to override default `<View>` style inside `<ScrollView>` component | Default to `null` |
| `contentContainerStyle` | `style` | No | This is the contentContainerStyle style to override default `<ScrollView>` contentContainerStyle style | Default to null |
| `containerStyle` | `style` | No | This is the style to override default outermost `<View>` style | Default to null |
| `scrollViewStyle` | `style` | No | This is the scrollview style to override default `<ScrollView>` style | Default to null |
| `innerContainerStyle` | `style` | No | This is the inner content style to override default `<View>` style inside `<ScrollView>` component | Default to null |
| `alwaysShowTitle` | `bool` | No | This is to determine whether show or hide the title after scroll | Default to `true` |
| `alwaysShowNavBar` | `bool` | No | This is to determine whether show or hide the navBar before scroll | Default to `true` |
| `alwaysShowNavBar` | `bool` | No | This is to determine whether show or hide the navBar before scroll | Default to `true` |
| `scrollViewProps` | `object` | No | This is to override default scroll view properties | Default to `{}` |
19 changes: 13 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,29 +318,30 @@ class RNParallax extends Component {

renderScrollView() {
const {
renderContent, scrollEventThrottle, contentContainerStyle, containerStyle,
renderContent, scrollEventThrottle, scrollViewStyle, contentContainerStyle, innerContainerStyle, scrollViewProps,
} = this.props;
const { scrollY } = this.state;
return (
<Animated.ScrollView
style={styles.scrollView}
style={[styles.scrollView, scrollViewStyle]}
contentContainerStyle={contentContainerStyle}
scrollEventThrottle={scrollEventThrottle}
onScroll={Animated.event(
[{ nativeEvent: { contentOffset: { y: scrollY } } }],
)}
contentContainerStyle={contentContainerStyle}
{...scrollViewProps}
>
<View style={[{ marginTop: this.getHeaderMaxHeight() }, containerStyle]}>
<View style={[{ marginTop: this.getHeaderMaxHeight() }, innerContainerStyle]}>
{renderContent()}
</View>
</Animated.ScrollView>
);
}

render() {
const { navbarColor, statusBarColor } = this.props;
const { navbarColor, statusBarColor, containerStyle } = this.props;
return (
<View style={styles.container}>
<View style={[styles.container, containerStyle]}>
<StatusBar
backgroundColor={statusBarColor || navbarColor}
/>
Expand Down Expand Up @@ -368,10 +369,13 @@ RNParallax.propTypes = {
extraScrollHeight: PropTypes.number,
backgroundImageScale: PropTypes.number,
contentContainerStyle: PropTypes.any,
innerContainerStyle: PropTypes.any,
scrollViewStyle: PropTypes.any,
containerStyle: PropTypes.any,
alwaysShowTitle: PropTypes.bool,
alwaysShowNavBar: PropTypes.bool,
statusBarColor: PropTypes.string,
scrollViewProps: PropTypes.object,
};

RNParallax.defaultProps = {
Expand All @@ -387,10 +391,13 @@ RNParallax.defaultProps = {
extraScrollHeight: DEFAULT_EXTRA_SCROLL_HEIGHT,
backgroundImageScale: DEFAULT_BACKGROUND_IMAGE_SCALE,
contentContainerStyle: null,
innerContainerStyle: null,
scrollViewStyle: null,
containerStyle: null,
alwaysShowTitle: true,
alwaysShowNavBar: true,
statusBarColor: null,
scrollViewProps: {},
};

export default RNParallax;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-parallax-header",
"version": "1.1.1",
"version": "1.1.2",
"description": "A react native scroll view component with Parallax header :p",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 90a3ec7

Please sign in to comment.