Skip to content
This repository was archived by the owner on May 13, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Libraries/ScrollView/ScrollView.web.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -360,7 +375,7 @@ class ScrollView extends React.Component {
}

let props = {
...this.props,
...otherProps,
alwaysBounceHorizontal,
alwaysBounceVertical,
style: ([styles.base, this.props.style]: ?Array<any>),
Expand Down Expand Up @@ -400,6 +415,7 @@ let styles = StyleSheet.create({
flex: 1,
},
contentContainer: {
position: 'absolute',
minWidth: '100%',
},
contentContainerHorizontal: {
Expand Down
3 changes: 3 additions & 0 deletions Libraries/StyleSheet/setDefaultStyle.web.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ function appendSytle({
bottom: 0;
overflow: hidden;
}
.${rootClassName} > .${viewClassName} {
height: 100%;
}
.${rootClassName} .${viewClassName} {
position: relative;
${boxStyle}
Expand Down
4 changes: 4 additions & 0 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ var Platform = require('ReactPlatform');
LayoutAnimation.configureNext(...)
}
```
5. ScrollView 需要指定高度
```js
<ScrollView style={{height: 235}} horizontal={true}></ScrollView>
```

## 任务脚本

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ As mentioned above, the HasteResolverPlugin plugin will help webpack to compile
}
```

5. Should manually specify the height of ScrollView
```js
<ScrollView style={{height: 235}} horizontal={true} />
```

### React Native compatible

#### Components
Expand Down