Fix regression of VirtualizedList jumpy header (#22025)

Summary:
Fixes #20956, #21361, #21198, #21468
Keeps the intended outcome of #18105
Pull Request resolved: https://github.com/facebook/react-native/pull/22025

Differential Revision: D13941915

Pulled By: cpojer

fbshipit-source-id: 59a0a834ea2d0dd4678e80a82ddaf95cecf87d38
This commit is contained in:
Danilo Bürger 2019-02-04 08:11:51 -08:00 committed by Facebook Github Bot
parent cca1cdf9b3
commit e4fd9babe0
1 changed files with 4 additions and 1 deletions

View File

@ -806,7 +806,10 @@ class VirtualizedList extends React.PureComponent<Props, State> {
if (stickyIndicesFromProps.has(ii + stickyOffset)) { if (stickyIndicesFromProps.has(ii + stickyOffset)) {
const initBlock = this._getFrameMetricsApprox(lastInitialIndex); const initBlock = this._getFrameMetricsApprox(lastInitialIndex);
const stickyBlock = this._getFrameMetricsApprox(ii); const stickyBlock = this._getFrameMetricsApprox(ii);
const leadSpace = stickyBlock.offset - initBlock.offset; const leadSpace =
stickyBlock.offset -
initBlock.offset -
(this.props.initialScrollIndex ? 0 : initBlock.length);
cells.push( cells.push(
<View key="$sticky_lead" style={{[spacerKey]: leadSpace}} />, <View key="$sticky_lead" style={{[spacerKey]: leadSpace}} />,
); );