From 39dda674ac55913748746402b5c769c5ede1e7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danilo=20B=C3=BCrger?= Date: Tue, 7 May 2019 14:15:44 +0200 Subject: [PATCH 1/2] Adjust scrollToLocation when using sticky section headers --- Libraries/Lists/VirtualizedSectionList.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Libraries/Lists/VirtualizedSectionList.js b/Libraries/Lists/VirtualizedSectionList.js index 90e560c608f1ed..8cbbf49b576b41 100644 --- a/Libraries/Lists/VirtualizedSectionList.js +++ b/Libraries/Lists/VirtualizedSectionList.js @@ -149,7 +149,15 @@ 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 = { + viewOffset, ...params, index, }; From e38b0a3166a19b7b7941ea0e58bc3f8ed96bc571 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Tue, 7 May 2019 15:54:06 +0100 Subject: [PATCH 2/2] Update VirtualizedSectionList.js --- Libraries/Lists/VirtualizedSectionList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Lists/VirtualizedSectionList.js b/Libraries/Lists/VirtualizedSectionList.js index 8cbbf49b576b41..ceb039ba2e9ec5 100644 --- a/Libraries/Lists/VirtualizedSectionList.js +++ b/Libraries/Lists/VirtualizedSectionList.js @@ -157,8 +157,8 @@ class VirtualizedSectionList< viewOffset = frame.length; } const toIndexParams = { - viewOffset, ...params, + viewOffset, index, }; this._listRef.scrollToIndex(toIndexParams);