From b364c3ad90f6547c0463c6ead6de0069bbfb1d1d Mon Sep 17 00:00:00 2001 From: huangqi03 Date: Fri, 13 May 2016 15:58:22 +0800 Subject: [PATCH 1/2] fix ScrollView --- Libraries/ScrollView/ScrollView.web.js | 18 +++++++++++++++++- Libraries/StyleSheet/setDefaultStyle.web.js | 3 +++ README-zh.md | 6 ++++++ README.md | 5 +++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Libraries/ScrollView/ScrollView.web.js b/Libraries/ScrollView/ScrollView.web.js index 3d5f303..199b1df 100644 --- a/Libraries/ScrollView/ScrollView.web.js +++ b/Libraries/ScrollView/ScrollView.web.js @@ -19,6 +19,7 @@ import autobind from 'autobind-decorator'; const SCROLLVIEW = 'ScrollView'; const INNERVIEW = 'InnerScrollView'; +const CONTENT_EXT_STYLE = ['padding', 'paddingTop', 'paddingBottom', 'paddingLeft', 'paddingRight']; /** * Component that wraps platform ScrollView while providing @@ -319,10 +320,24 @@ class ScrollView extends React.Component { } render() { + let { + style, + ...otherProps + } = this.props; + + let contentContainerExtStyle = {}; + + for (let i = 0; i < CONTENT_EXT_STYLE.length; i++) { + if (typeof style[CONTENT_EXT_STYLE[i]] === 'number') { + contentContainerExtStyle[CONTENT_EXT_STYLE[i]] = style[CONTENT_EXT_STYLE[i]]; + } + } + let contentContainerStyle = [ styles.contentContainer, this.props.horizontal && styles.contentContainerHorizontal, this.props.contentContainerStyle, + contentContainerExtStyle, ]; // if (__DEV__ && this.props.style) { // let style = flattenStyle(this.props.style); @@ -360,7 +375,7 @@ class ScrollView extends React.Component { } let props = { - ...this.props, + ...otherProps, alwaysBounceHorizontal, alwaysBounceVertical, style: ([styles.base, this.props.style]: ?Array), @@ -400,6 +415,7 @@ let styles = StyleSheet.create({ flex: 1, }, contentContainer: { + position: 'absolute', minWidth: '100%', }, contentContainerHorizontal: { diff --git a/Libraries/StyleSheet/setDefaultStyle.web.js b/Libraries/StyleSheet/setDefaultStyle.web.js index fa865a1..514922e 100644 --- a/Libraries/StyleSheet/setDefaultStyle.web.js +++ b/Libraries/StyleSheet/setDefaultStyle.web.js @@ -45,6 +45,9 @@ function appendSytle({ bottom: 0; overflow: hidden; } + .${rootClassName} > .${viewClassName} { + height: 100%; + } .${rootClassName} .${viewClassName} { position: relative; ${boxStyle} diff --git a/README-zh.md b/README-zh.md index 9fc6444..797bdd4 100644 --- a/README-zh.md +++ b/README-zh.md @@ -148,6 +148,12 @@ var Platform = require('ReactPlatform'); LayoutAnimation.configureNext(...) } ``` +5. ScrollView 需要指定高度 + ```js + // 手动指定滚动区域高度、子元素不会自动撑起ScrollView + + + ``` ## 任务脚本 diff --git a/README.md b/README.md index 4e516f7..0d6a635 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,11 @@ As mentioned above, the HasteResolverPlugin plugin will help webpack to compile } ``` +5. Should manually specify the height of ScrollView + ```js + + ``` + ### React Native compatible #### Components From 7d413732839a1d20b3ef54a6044e1f948ef903a3 Mon Sep 17 00:00:00 2001 From: huangqi03 Date: Fri, 13 May 2016 16:04:45 +0800 Subject: [PATCH 2/2] fixe --- README-zh.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README-zh.md b/README-zh.md index 797bdd4..c706d9c 100644 --- a/README-zh.md +++ b/README-zh.md @@ -150,9 +150,7 @@ var Platform = require('ReactPlatform'); ``` 5. ScrollView 需要指定高度 ```js - // 手动指定滚动区域高度、子元素不会自动撑起ScrollView - - + ``` ## 任务脚本