From 4d5f85ed426cfb43dc5e63f915e416a47d76b965 Mon Sep 17 00:00:00 2001 From: Dustin Savery Date: Mon, 28 Jan 2019 03:18:46 -0800 Subject: [PATCH] Fixing overscrolling issue on Virtualized List (#23181) Summary: Changelog: ---------- [iOS][fixed] Fixed overscroll behavior on iOS virtualized lists (Fixes #18098) Pull Request resolved: https://github.com/facebook/react-native/pull/23181 Differential Revision: D13838579 Pulled By: cpojer fbshipit-source-id: 2ec5787218ecca0e01aaf31bfbb7d630cf9f1f09 --- Libraries/Lists/VirtualizedList.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index f6a9c6e2ee7c6e..a14bcde7be8305 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -330,13 +330,20 @@ class VirtualizedList extends React.PureComponent { return; } const frame = this._getFrameMetricsApprox(index); - const offset = + const maxScroll = + this._scrollMetrics.contentLength - this._scrollMetrics.visibleLength; + let offset = Math.max( 0, frame.offset - (viewPosition || 0) * (this._scrollMetrics.visibleLength - frame.length), ) - (viewOffset || 0); + + /* Fix for overscrolling */ + if (offset > maxScroll) { + offset = maxScroll; + } /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment * suppresses an error when upgrading Flow's support for React. To see the * error delete this comment and run Flow. */