From 18ecfca2889d0217f564ac511b12bf0ce1104bd9 Mon Sep 17 00:00:00 2001 From: JakubDrobnik Date: Wed, 21 Nov 2018 12:55:09 +0100 Subject: [PATCH] Small fixes --- src/infinite_scroll.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/infinite_scroll.js b/src/infinite_scroll.js index 9dec12f..c8a47a7 100644 --- a/src/infinite_scroll.js +++ b/src/infinite_scroll.js @@ -105,14 +105,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); + await scrollTo(page, elementToScroll, scrollInfo.scrollHeight + scrollInfo.clientHeight); } 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); + await scrollTo(page, elementToScroll, scrollInfo.scrollHeight + scrollInfo.clientHeight); logInfo(`Infinite scroll finished (${stringifyScrollInfo(scrollInfo)} resourcesStats=${JSON.stringify(resourcesStats)})`); } catch (err) {