Small fix

This commit is contained in:
JakubDrobnik 2018-11-21 14:27:45 +01:00
parent 34e3077a59
commit e0e4d376f5

View File

@ -101,14 +101,14 @@ module.exports = async (page, maxHeight, elementToScroll = 'body') => {
// If the page is scrolled to the very bottom or beyond maximum height, we are done
if (scrollInfo.scrollTop + scrollInfo.clientHeight >= Math.min(scrollInfo.scrollHeight, maxHeight)) break;
// Otherwise we try to scroll down
await scrollTo(page, elementToScroll, scrollInfo.scrollHeight + scrollInfo.clientHeight);
await scrollTo(page, elementToScroll, maxHeight);
}
await sleep(defaultScrollDelay);
}
// Scroll back up, otherwise the screenshot of the browser would only show the bottom of
// the page
await scrollTo(page, elementToScroll, scrollInfo.scrollHeight + scrollInfo.clientHeight);
await scrollTo(page, elementToScroll, maxHeight);
logInfo(`Infinite scroll finished (${stringifyScrollInfo(scrollInfo)} resourcesStats=${JSON.stringify(resourcesStats)})`);
} catch (err) {