38 lines
929 B
JavaScript
38 lines
929 B
JavaScript
// Scroll Animation Example
|
|
// Smoothly scrolls through the entire page before capturing
|
|
|
|
console.log('🎬 Starting scroll animation...');
|
|
|
|
// Scroll to bottom smoothly
|
|
await page.evaluate(async () => {
|
|
await new Promise((resolve) => {
|
|
let totalHeight = 0;
|
|
const distance = 100;
|
|
const timer = setInterval(() => {
|
|
const scrollHeight = document.body.scrollHeight;
|
|
window.scrollBy(0, distance);
|
|
totalHeight += distance;
|
|
|
|
if (totalHeight >= scrollHeight) {
|
|
clearInterval(timer);
|
|
resolve();
|
|
}
|
|
}, 100);
|
|
});
|
|
});
|
|
|
|
console.log('✓ Scrolled to bottom');
|
|
|
|
// Wait a bit at bottom
|
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
|
|
// Scroll back to top
|
|
await page.evaluate(() => {
|
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
});
|
|
|
|
console.log('✓ Scrolled back to top');
|
|
|
|
// Wait for scroll to finish
|
|
await new Promise(resolve => setTimeout(resolve, 1000));
|