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] 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, };