From dbc23466b3ec63453ca57e6e24e1efd23c104b8f Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Thu, 28 Jun 2018 15:24:25 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20account=20for=20`ListHeaderComponent`=20?= =?UTF-8?q?length=20when=20calculating=20offset=E2=80=A6=20(#17415)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: … in VirtualizedList - fixes #16612 Issue is detailed in #16612 I need `onViewableItemsChanged` to account for the length of any ListHeaderComponents I couldn't find any tests that currently cover the use-case of a VirtualizedList + ListComponent + scroll with onViewableItemsChanged, so I have not added any tests - all previous tests pass however. [GENERAL][BUGFIX][VirtualizedList] - account for `ListHeaderComponent` length Closes https://github.com/facebook/react-native/pull/17415 Differential Revision: D8683555 Pulled By: hramos fbshipit-source-id: 05df7b79c16e3c07c12468e782f3c4b0bdce7403 --- Libraries/Lists/VirtualizedList.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 56364823f06d49..47b6b5f083e1d7 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -1217,7 +1217,9 @@ class VirtualizedList extends React.PureComponent { } _selectOffset(metrics: $ReadOnly<{x: number, y: number}>): number { - return !this.props.horizontal ? metrics.y : metrics.x; + return ( + (!this.props.horizontal ? metrics.y : metrics.x) - this._headerLength + ); } _maybeCallOnEndReached() {