mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-06 22:37:14 +08:00
Adjust scrollToLocation when using sticky section headers (#24735)
Summary: When using `scrollToLocation` together with `stickySectionHeadersEnabled` in a `SectionList`, the length of the section header is not accounted for when scrolling to any item except the header. [General] [Fixed] - Adjust scrollToLocation when using sticky section headers Pull Request resolved: https://github.com/facebook/react-native/pull/24735 Differential Revision: D15240953 Pulled By: cpojer fbshipit-source-id: fd7121d990c5b01533e456bdfa39bebf6245fa80
This commit is contained in:
committed by
Facebook Github Bot
parent
509a07b207
commit
d376a444e3
@@ -149,8 +149,16 @@ class VirtualizedSectionList<
|
||||
for (let i = 0; i < params.sectionIndex; i++) {
|
||||
index += this.props.getItemCount(this.props.sections[i].data) + 2;
|
||||
}
|
||||
let viewOffset = 0;
|
||||
if (params.itemIndex > 0 && this.props.stickySectionHeadersEnabled) {
|
||||
const frame = this._listRef._getFrameMetricsApprox(
|
||||
index - params.itemIndex,
|
||||
);
|
||||
viewOffset = frame.length;
|
||||
}
|
||||
const toIndexParams = {
|
||||
...params,
|
||||
viewOffset,
|
||||
index,
|
||||
};
|
||||
this._listRef.scrollToIndex(toIndexParams);
|
||||
|
||||
Reference in New Issue
Block a user