From 6603cef95cd30fcc05330707d4ce10a2c4e22046 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 1 Jun 2016 04:18:36 -0700 Subject: [PATCH] Fix ScrollView to work correctly for new css-layout Reviewed By: sahrens Differential Revision: D3367140 fbshipit-source-id: ea470f289c92ebca71543a9b9328a7a5ed6d572b --- Libraries/Components/ScrollView/ScrollView.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index ad5e9edbf..52e20aff6 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -468,11 +468,13 @@ const ScrollView = React.createClass({ this.props.alwaysBounceVertical : !this.props.horizontal; + const baseStyle = this.props.horizontal ? styles.baseHorizontal : styles.baseVertical; + const props = { ...this.props, alwaysBounceHorizontal, alwaysBounceVertical, - style: ([styles.base, this.props.style]: ?Array), + style: ([baseStyle, this.props.style]: ?Array), onTouchStart: this.scrollResponderHandleTouchStart, onTouchMove: this.scrollResponderHandleTouchMove, onTouchEnd: this.scrollResponderHandleTouchEnd, @@ -529,7 +531,7 @@ const ScrollView = React.createClass({ return React.cloneElement( refreshControl, {style: props.style}, - + {contentContainer} ); @@ -544,11 +546,14 @@ const ScrollView = React.createClass({ }); const styles = StyleSheet.create({ - base: { + baseVertical: { flex: 1, }, + baseHorizontal: { + flex: 1, + flexDirection: 'row', + }, contentContainerHorizontal: { - alignSelf: 'flex-start', flexDirection: 'row', }, });