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