mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Better RTL support especially for ScrollView's
Reviewed By: fkgozali Differential Revision: D4478913 fbshipit-source-id: 525c17fa109ad3c35161b10940776f1426ba2535
This commit is contained in:
committed by
Facebook Github Bot
parent
d82f2553fb
commit
91910d87de
@@ -483,6 +483,30 @@ const ScrollView = React.createClass({
|
||||
},
|
||||
|
||||
render: function() {
|
||||
let ScrollViewClass;
|
||||
let ScrollContentContainerViewClass;
|
||||
if (Platform.OS === 'ios') {
|
||||
ScrollViewClass = RCTScrollView;
|
||||
ScrollContentContainerViewClass = RCTScrollContentView;
|
||||
} else if (Platform.OS === 'android') {
|
||||
if (this.props.horizontal) {
|
||||
ScrollViewClass = AndroidHorizontalScrollView;
|
||||
} else {
|
||||
ScrollViewClass = AndroidScrollView;
|
||||
}
|
||||
ScrollContentContainerViewClass = View;
|
||||
}
|
||||
|
||||
invariant(
|
||||
ScrollViewClass !== undefined,
|
||||
'ScrollViewClass must not be undefined'
|
||||
);
|
||||
|
||||
invariant(
|
||||
ScrollContentContainerViewClass !== undefined,
|
||||
'ScrollContentContainerViewClass must not be undefined'
|
||||
);
|
||||
|
||||
const contentContainerStyle = [
|
||||
this.props.horizontal && styles.contentContainerHorizontal,
|
||||
this.props.contentContainerStyle,
|
||||
@@ -507,14 +531,14 @@ const ScrollView = React.createClass({
|
||||
}
|
||||
|
||||
const contentContainer =
|
||||
<View
|
||||
<ScrollContentContainerViewClass
|
||||
{...contentSizeChangeProps}
|
||||
ref={this._setInnerViewRef}
|
||||
style={contentContainerStyle}
|
||||
removeClippedSubviews={this.props.removeClippedSubviews}
|
||||
collapsable={false}>
|
||||
{this.props.children}
|
||||
</View>;
|
||||
</ScrollContentContainerViewClass>;
|
||||
|
||||
const alwaysBounceHorizontal =
|
||||
this.props.alwaysBounceHorizontal !== undefined ?
|
||||
@@ -559,21 +583,6 @@ const ScrollView = React.createClass({
|
||||
props.decelerationRate = processDecelerationRate(decelerationRate);
|
||||
}
|
||||
|
||||
let ScrollViewClass;
|
||||
if (Platform.OS === 'ios') {
|
||||
ScrollViewClass = RCTScrollView;
|
||||
} else if (Platform.OS === 'android') {
|
||||
if (this.props.horizontal) {
|
||||
ScrollViewClass = AndroidHorizontalScrollView;
|
||||
} else {
|
||||
ScrollViewClass = AndroidScrollView;
|
||||
}
|
||||
}
|
||||
invariant(
|
||||
ScrollViewClass !== undefined,
|
||||
'ScrollViewClass must not be undefined'
|
||||
);
|
||||
|
||||
const refreshControl = this.props.refreshControl;
|
||||
if (refreshControl) {
|
||||
if (Platform.OS === 'ios') {
|
||||
@@ -626,7 +635,7 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
});
|
||||
|
||||
let nativeOnlyProps, AndroidScrollView, AndroidHorizontalScrollView, RCTScrollView;
|
||||
let nativeOnlyProps, AndroidScrollView, AndroidHorizontalScrollView, RCTScrollView, RCTScrollContentView;
|
||||
if (Platform.OS === 'android') {
|
||||
nativeOnlyProps = {
|
||||
nativeOnly: {
|
||||
@@ -649,6 +658,7 @@ if (Platform.OS === 'android') {
|
||||
}
|
||||
};
|
||||
RCTScrollView = requireNativeComponent('RCTScrollView', ScrollView, nativeOnlyProps);
|
||||
RCTScrollContentView = requireNativeComponent('RCTScrollContentView', View);
|
||||
}
|
||||
|
||||
module.exports = ScrollView;
|
||||
|
||||
Reference in New Issue
Block a user