Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,22 @@ export const loopTracker = {
};

export const scrollBarStorage = {
key: '_infiniteScrollHeight',
key: '_infiniteScrollPosition',
getScrollElm(elm) {
return elm === window ? document.documentElement : elm;
},
save(elm) {
const target = this.getScrollElm(elm);

// save scroll height on the scroll parent
target[this.key] = target.scrollHeight;
// save scroll height and top position on the scroll parent
target[this.key] = [target.scrollHeight, target.scrollTop];
},
restore(elm) {
const target = this.getScrollElm(elm);

/* istanbul ignore else */
if (typeof target[this.key] === 'number') {
target.scrollTop = target.scrollHeight - target[this.key] + target.scrollTop;
if (typeof target[this.key][0] === 'number' && typeof target[this.key][1] === 'number') {
target.scrollTop = target.scrollHeight - target[this.key][0] + target[this.key][1];
}

this.remove(target);
Expand Down