Skip to content

Commit 3fb4643

Browse files
authored
Merge pull request #32 from alaycock/master
Allow custom styles on content container
2 parents f348f07 + 369214b commit 3fb4643

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/index.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const IPropTypes = {
4141
renderForeground: func,
4242
renderScrollComponent: func,
4343
renderStickyHeader: func,
44-
stickyHeaderHeight: number
44+
stickyHeaderHeight: number,
45+
contentContainerStyle: View.propTypes.style
4546
};
4647

4748
class ParallaxScrollView extends Component {
@@ -79,12 +80,13 @@ class ParallaxScrollView extends Component {
7980
renderStickyHeader,
8081
stickyHeaderHeight,
8182
style,
83+
contentContainerStyle,
8284
...scrollViewProps
8385
} = this.props;
8486

8587
const background = this._renderBackground({ fadeOutBackground, backgroundScrollSpeed, backgroundColor, parallaxHeaderHeight, stickyHeaderHeight, renderBackground });
8688
const foreground = this._renderForeground({ fadeOutForeground, parallaxHeaderHeight, stickyHeaderHeight, renderForeground: renderForeground || renderParallaxHeader });
87-
const bodyComponent = this._wrapChildren(children, { contentBackgroundColor, stickyHeaderHeight });
89+
const bodyComponent = this._wrapChildren(children, { contentBackgroundColor, stickyHeaderHeight, contentContainerStyle });
8890
const footerSpacer = this._renderFooterSpacer({ contentBackgroundColor });
8991
const maybeStickyHeader = this._maybeRenderStickyHeader({ parallaxHeaderHeight, stickyHeaderHeight, backgroundColor, renderFixedHeader, renderStickyHeader });
9092
const scrollElement = renderScrollComponent(scrollViewProps);
@@ -240,11 +242,16 @@ class ParallaxScrollView extends Component {
240242
);
241243
}
242244

243-
_wrapChildren(children, { contentBackgroundColor, stickyHeaderHeight }) {
245+
_wrapChildren(children, { contentBackgroundColor, stickyHeaderHeight, contentContainerStyle }) {
244246
const { viewHeight } = this.state;
247+
const containerStyles = [{backgroundColor: contentBackgroundColor}];
248+
249+
if(contentContainerStyle)
250+
containerStyles.push(contentContainerStyle);
251+
245252
return (
246253
<View
247-
style={{ backgroundColor: contentBackgroundColor }}
254+
style={containerStyles}
248255
onLayout={e => {
249256
// Adjust the bottom height so we can scroll the parallax header all the way up.
250257
const { nativeEvent: { layout: { height } } } = e;
@@ -321,7 +328,8 @@ ParallaxScrollView.defaultProps = {
321328
renderBackground: renderEmpty,
322329
renderParallaxHeader: renderEmpty, // Deprecated (will be removed in 0.18.0)
323330
renderForeground: null,
324-
stickyHeaderHeight: 0
331+
stickyHeaderHeight: 0,
332+
contentContainerStyle: null
325333
};
326334

327335
module.exports = ParallaxScrollView;

0 commit comments

Comments
 (0)