chore: init
This commit is contained in:
37
examples/scroll-animation.js
Normal file
37
examples/scroll-animation.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// 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));
|
||||
Reference in New Issue
Block a user