I have a function to handle the scroll in puppeteer.
async function autoScroll(page, custom_scroll = null) {
await page.evaluate(async () => {
await new Promise((resolve, reject) => {
var totalHeight = 0;
var distance = 100;
var timer = setInterval(() => {
var scrollHeight = document.body.scrollHeight-1200;
window.scrollBy(0, distance);
totalHeight += distance;
if (totalHeight >= scrollHeight) {
clearInterval(timer);
resolve();
}
}, 100);
});
});
}
I want to pass custom_scroll and use it in document.body.scrollHeight-1200
But if I use document.body.scrollHeight-custom_scroll
I get an error