From d1a5d94916806d4dee2a940ca782f3b5d4f88043 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 22 Nov 2016 16:47:56 +0000 Subject: [PATCH] Make the unpagination process less aggressive This increases `UNPAGINATION_PADDING` (see the ASCII on ScrollPanel.js, `_getExcessHeight`), and also debounces unfilling requests made for 200ms. This forces unfilling requests not to be sent unless the next 200ms has no scrolling, effectively. --- src/components/structures/ScrollPanel.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/structures/ScrollPanel.js b/src/components/structures/ScrollPanel.js index 36dbf041e8..f7f954bc0f 100644 --- a/src/components/structures/ScrollPanel.js +++ b/src/components/structures/ScrollPanel.js @@ -25,7 +25,7 @@ var DEBUG_SCROLL = false; // The amount of extra scroll distance to allow prior to unfilling. // See _getExcessHeight. -const UNPAGINATION_PADDING = 500; +const UNPAGINATION_PADDING = 1500; if (DEBUG_SCROLL) { // using bind means that we get to keep useful line numbers in the console @@ -361,7 +361,14 @@ module.exports = React.createClass({ } if (markerScrollToken) { - this.props.onUnfillRequest(backwards, markerScrollToken); + // Use a debouncer to prevent multiple unfill calls in quick succession + // This is to make the unfilling process less aggressive + if (this._unfillDebouncer) { + clearTimeout(this._unfillDebouncer); + } + this._unfillDebouncer = setTimeout(() => { + this.props.onUnfillRequest(backwards, markerScrollToken); + }, 200); } },