mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 12:45:37 +08:00
[React Native] Fix scroll view sticky headers
Summary: The `ScrollView` component tells the native side the subview indices of the views to make sticky. The problem is that, once layout-only views are collapsed, the indices are no longer reflective of the original views to make stick to the top.
This commit is contained in:
@@ -17,6 +17,7 @@ var PointPropType = require('PointPropType');
|
|||||||
var RCTScrollView = require('NativeModules').UIManager.RCTScrollView;
|
var RCTScrollView = require('NativeModules').UIManager.RCTScrollView;
|
||||||
var RCTScrollViewConsts = RCTScrollView.Constants;
|
var RCTScrollViewConsts = RCTScrollView.Constants;
|
||||||
var React = require('React');
|
var React = require('React');
|
||||||
|
var ReactChildren = require('ReactChildren');
|
||||||
var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
|
var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
|
||||||
var RCTUIManager = require('NativeModules').UIManager;
|
var RCTUIManager = require('NativeModules').UIManager;
|
||||||
var ScrollResponder = require('ScrollResponder');
|
var ScrollResponder = require('ScrollResponder');
|
||||||
@@ -277,13 +278,24 @@ var ScrollView = React.createClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var children = this.props.children;
|
||||||
|
if (this.props.stickyHeaderIndices) {
|
||||||
|
children = ReactChildren.map(children, (child) => {
|
||||||
|
if (child) {
|
||||||
|
return <View collapsible={false}>{child}</View>;
|
||||||
|
} else {
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var contentContainer =
|
var contentContainer =
|
||||||
<View
|
<View
|
||||||
collapsible={false}
|
collapsible={false}
|
||||||
ref={INNERVIEW}
|
ref={INNERVIEW}
|
||||||
style={contentContainerStyle}
|
style={contentContainerStyle}
|
||||||
removeClippedSubviews={this.props.removeClippedSubviews}>
|
removeClippedSubviews={this.props.removeClippedSubviews}>
|
||||||
{this.props.children}
|
{children}
|
||||||
</View>;
|
</View>;
|
||||||
|
|
||||||
var alwaysBounceHorizontal =
|
var alwaysBounceHorizontal =
|
||||||
|
|||||||
Reference in New Issue
Block a user