Merge pull request #2865 from matrix-org/bwindels/smallscrollfixes

Small scroll fixes
This commit is contained in:
Bruno Windels 2019-04-03 07:29:13 +00:00 committed by GitHub
commit a11786884e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,8 +29,11 @@ const UNPAGINATION_PADDING = 6000;
// The number of milliseconds to debounce calls to onUnfillRequest, to prevent // The number of milliseconds to debounce calls to onUnfillRequest, to prevent
// many scroll events causing many unfilling requests. // many scroll events causing many unfilling requests.
const UNFILL_REQUEST_DEBOUNCE_MS = 200; const UNFILL_REQUEST_DEBOUNCE_MS = 200;
// _updateHeight makes the height a ceiled multiple of this so we
const PAGE_SIZE = 200; // don't have to update the height too often. It also allows the user
// to scroll past the pagination spinner a bit so they don't feel blocked so
// much while the content loads.
const PAGE_SIZE = 400;
let debuglog; let debuglog;
if (DEBUG_SCROLL) { if (DEBUG_SCROLL) {
@ -222,10 +225,12 @@ module.exports = React.createClass({
// whether it will stay that way when the children update. // whether it will stay that way when the children update.
isAtBottom: function() { isAtBottom: function() {
const sn = this._getScrollNode(); const sn = this._getScrollNode();
// fractional values for scrollTop happen on certain browsers/platforms // fractional values (both too big and too small)
// for scrollTop happen on certain browsers/platforms
// when scrolled all the way down. E.g. Chrome 72 on debian. // when scrolled all the way down. E.g. Chrome 72 on debian.
// so ceil everything upwards to make sure it aligns. // so check difference <= 1;
return Math.ceil(sn.scrollTop) === Math.ceil(sn.scrollHeight - sn.clientHeight); return Math.abs(sn.scrollHeight - (sn.scrollTop + sn.clientHeight)) <= 1;
}, },
// returns the vertical height in the given direction that can be removed from // returns the vertical height in the given direction that can be removed from