take into account that node might not be in DOM while updating height
This commit is contained in:
parent
88f039fe44
commit
c306181fcd
1 changed files with 15 additions and 8 deletions
|
@ -624,18 +624,25 @@ module.exports = React.createClass({
|
||||||
this._bottomGrowth = 0;
|
this._bottomGrowth = 0;
|
||||||
const newHeight = this._getListHeight();
|
const newHeight = this._getListHeight();
|
||||||
|
|
||||||
if (this.scrollState.stuckAtBottom) {
|
const scrollState = this.scrollState;
|
||||||
|
if (scrollState.stuckAtBottom) {
|
||||||
itemlist.style.height = `${newHeight}px`;
|
itemlist.style.height = `${newHeight}px`;
|
||||||
sn.scrollTop = sn.scrollHeight;
|
sn.scrollTop = sn.scrollHeight;
|
||||||
debuglog("xxx updateHeight to", newHeight);
|
debuglog("xxx updateHeight to", newHeight);
|
||||||
} else {
|
} else if (scrollState.trackedScrollToken) {
|
||||||
const trackedNode = this._getTrackedNode();
|
const trackedNode = this._getTrackedNode();
|
||||||
const oldTop = trackedNode.offsetTop;
|
// if the timeline has been reloaded
|
||||||
itemlist.style.height = `${newHeight}px`;
|
// this can be called before scrollToBottom or whatever has been called
|
||||||
const newTop = trackedNode.offsetTop;
|
// so don't do anything of the node has disappeared from
|
||||||
const topDiff = newTop - oldTop;
|
// the currently filled piece of the timeline
|
||||||
sn.scrollTop = sn.scrollTop + topDiff;
|
if (trackedNode) {
|
||||||
debuglog("xxx updateHeight to", newHeight, topDiff, Date.now() - startTs);
|
const oldTop = trackedNode.offsetTop;
|
||||||
|
itemlist.style.height = `${newHeight}px`;
|
||||||
|
const newTop = trackedNode.offsetTop;
|
||||||
|
const topDiff = newTop - oldTop;
|
||||||
|
sn.scrollTop = sn.scrollTop + topDiff;
|
||||||
|
debuglog("xxx updateHeight to", newHeight, topDiff, Date.now() - startTs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue