Fix ScrollView to work correctly for new css-layout

Reviewed By: sahrens

Differential Revision: D3367140

fbshipit-source-id: ea470f289c92ebca71543a9b9328a7a5ed6d572b
This commit is contained in:
Emil Sjolander 2016-06-01 04:18:36 -07:00 committed by Facebook Github Bot 4
parent 4391ef218b
commit 6603cef95c
1 changed files with 9 additions and 4 deletions

View File

@ -468,11 +468,13 @@ const ScrollView = React.createClass({
this.props.alwaysBounceVertical : this.props.alwaysBounceVertical :
!this.props.horizontal; !this.props.horizontal;
const baseStyle = this.props.horizontal ? styles.baseHorizontal : styles.baseVertical;
const props = { const props = {
...this.props, ...this.props,
alwaysBounceHorizontal, alwaysBounceHorizontal,
alwaysBounceVertical, alwaysBounceVertical,
style: ([styles.base, this.props.style]: ?Array<any>), style: ([baseStyle, this.props.style]: ?Array<any>),
onTouchStart: this.scrollResponderHandleTouchStart, onTouchStart: this.scrollResponderHandleTouchStart,
onTouchMove: this.scrollResponderHandleTouchMove, onTouchMove: this.scrollResponderHandleTouchMove,
onTouchEnd: this.scrollResponderHandleTouchEnd, onTouchEnd: this.scrollResponderHandleTouchEnd,
@ -529,7 +531,7 @@ const ScrollView = React.createClass({
return React.cloneElement( return React.cloneElement(
refreshControl, refreshControl,
{style: props.style}, {style: props.style},
<ScrollViewClass {...props} style={styles.base} ref={this._setScrollViewRef}> <ScrollViewClass {...props} style={baseStyle} ref={this._setScrollViewRef}>
{contentContainer} {contentContainer}
</ScrollViewClass> </ScrollViewClass>
); );
@ -544,11 +546,14 @@ const ScrollView = React.createClass({
}); });
const styles = StyleSheet.create({ const styles = StyleSheet.create({
base: { baseVertical: {
flex: 1, flex: 1,
}, },
baseHorizontal: {
flex: 1,
flexDirection: 'row',
},
contentContainerHorizontal: { contentContainerHorizontal: {
alignSelf: 'flex-start',
flexDirection: 'row', flexDirection: 'row',
}, },
}); });