diff --git a/src/components/structures/ScrollPanel.js b/src/components/structures/ScrollPanel.js index f7f954bc0f..31ac59c730 100644 --- a/src/components/structures/ScrollPanel.js +++ b/src/components/structures/ScrollPanel.js @@ -26,6 +26,9 @@ var DEBUG_SCROLL = false; // The amount of extra scroll distance to allow prior to unfilling. // See _getExcessHeight. const UNPAGINATION_PADDING = 1500; +// The number of milliseconds to debounce calls to onUnfillRequest, to prevent +// many scroll events causing many unfilling requests. +const UNFILL_REQUEST_DEBOUNCE_MS = 200; if (DEBUG_SCROLL) { // using bind means that we get to keep useful line numbers in the console @@ -367,8 +370,9 @@ module.exports = React.createClass({ clearTimeout(this._unfillDebouncer); } this._unfillDebouncer = setTimeout(() => { + this._unfillDebouncer = null; this.props.onUnfillRequest(backwards, markerScrollToken); - }, 200); + }, UNFILL_REQUEST_DEBOUNCE_MS); } },