Files
webshot/examples/animated-sections.js
2025-11-04 18:39:56 +01:00

34 lines
966 B
JavaScript

// Animated Sections Example
// Scrolls through page to trigger scroll-based animations
console.log('✨ Triggering scroll animations...');
// Get all sections
const sections = await page.evaluate(() => {
const elements = document.querySelectorAll('section, .section, [class*="section"]');
return Array.from(elements).map(el => el.offsetTop);
});
console.log(`Found ${sections.length} sections to animate`);
// Scroll to each section
for (let i = 0; i < sections.length; i++) {
await page.evaluate((top) => {
window.scrollTo({ top, behavior: 'smooth' });
}, sections[i]);
console.log(`✓ Scrolled to section ${i + 1}/${sections.length}`);
// Wait for animations to trigger
await new Promise(resolve => setTimeout(resolve, 800));
}
// Scroll back to top
await page.evaluate(() => {
window.scrollTo({ top: 0, behavior: 'smooth' });
});
await new Promise(resolve => setTimeout(resolve, 1000));
console.log('✓ All animations triggered');