/*
	Theme Name: Hello Elementor
	Theme URI: https://elementor.com/hello-theme/?utm_source=wp-themes&utm_campaign=theme-uri&utm_medium=wp-dash
	Description: Hello Elementor is a lightweight and minimalist WordPress theme that was built specifically to work seamlessly with the Elementor site builder plugin. The theme is free, open-source, and designed for users who want a flexible, easy-to-use, and customizable website. The theme, which is optimized for performance, provides a solid foundation for users to build their own unique designs using the Elementor drag-and-drop site builder. Its simplicity and flexibility make it a great choice for both beginners and experienced Web Creators.
	Author: Elementor Team
	Author URI: https://elementor.com/?utm_source=wp-themes&utm_campaign=author-uri&utm_medium=wp-dash
	Version: 3.4.4
	Stable tag: 3.4.4
	Requires at least: 6.0
	Tested up to: 6.8
	Requires PHP: 7.4
	License: GNU General Public License v3 or later.
	License URI: https://www.gnu.org/licenses/gpl-3.0.html
	Text Domain: hello-elementor
	Tags: accessibility-ready, flexible-header, custom-colors, custom-menu, custom-logo, featured-images, rtl-language-support, threaded-comments, translation-ready,
*/
// fullscreen-scroll-advanced.js
document.addEventListener('DOMContentLoaded', function() {
    
    gsap.registerPlugin(ScrollTrigger);
    
    const sections = gsap.utils.toArray('.scroll-section');
    
    sections.forEach((section, index) => {
        
        // 创建时间轴动画
        const tl = gsap.timeline({
            scrollTrigger: {
                trigger: section,
                start: 'top top',
                end: '+=200%',
                pin: true,
                scrub: 1,
                anticipatePin: 1,
                markers: false // 调试时设为 true 查看触发点
            }
        });
        
        // 动画序列
        tl.from(section, {
            opacity: 0,
            scale: 0.9,
            duration: 0.5
        })
        .from(section.querySelectorAll('.elementor-heading-title'), {
            y: 100,
            opacity: 0,
            stagger: 0.1,
            duration: 0.5
        }, '-=0.3')
        .from(section.querySelectorAll('.elementor-text-editor, .elementor-button'), {
            y: 50,
            opacity: 0,
            stagger: 0.1,
            duration: 0.5
        }, '-=0.2')
        .to(section, {
            opacity: 0,
            scale: 1.1,
            duration: 0.5
        }, '+=0.5');
    });
    
    // 添加视差效果到背景
    gsap.utils.toArray('.scroll-section .elementor-background-overlay').forEach(bg => {
        gsap.to(bg, {
            yPercent: 30,
            ease: 'none',
            scrollTrigger: {
                trigger: bg.closest('.scroll-section'),
                start: 'top top',
                end: 'bottom top',
                scrub: true
            }
        });
    });
});
