clearer naming in ScrollPanel

This commit is contained in:
Bruno Windels 2019-03-07 12:16:18 +01:00
parent 4e382b1dd9
commit 89b044f5d8

View file

@ -601,16 +601,17 @@ module.exports = React.createClass({
}
const scrollNode = this._getScrollNode();
const scrollBottom = scrollNode.scrollTop + scrollNode.clientHeight;
const scrollTop = scrollNode.scrollTop;
const viewportBottom = scrollTop + scrollNode.clientHeight;
const nodeBottom = node.offsetTop + node.clientHeight;
const scrollDelta = nodeBottom + pixelOffset - scrollBottom;
const intendedViewportBottom = nodeBottom + pixelOffset;
const scrollDelta = intendedViewportBottom - viewportBottom;
debuglog("ScrollPanel: scrolling to token '" + scrollToken + "'+" +
pixelOffset + " (delta: "+scrollDelta+")");
if (scrollDelta != 0) {
this._setScrollTop(scrollNode.scrollTop + scrollDelta);
if (scrollDelta !== 0) {
this._setScrollTop(scrollTop + scrollDelta);
}
},
@ -622,7 +623,7 @@ module.exports = React.createClass({
}
const scrollNode = this._getScrollNode();
const scrollBottom = scrollNode.scrollTop + scrollNode.clientHeight;
const viewportBottom = scrollNode.scrollTop + scrollNode.clientHeight;
const itemlist = this.refs.itemlist;
const messages = itemlist.children;
@ -636,7 +637,7 @@ module.exports = React.createClass({
node = messages[i];
// break at the first message (coming from the bottom)
// that has it's offsetTop above the bottom of the viewport.
if (node.offsetTop < scrollBottom) {
if (node.offsetTop < viewportBottom) {
// Use this node as the scrollToken
break;
}
@ -652,7 +653,7 @@ module.exports = React.createClass({
this.scrollState = {
stuckAtBottom: false,
trackedScrollToken: node.dataset.scrollTokens.split(',')[0],
pixelOffset: scrollBottom - nodeBottom,
pixelOffset: viewportBottom - nodeBottom,
};
},