File size: 3,494 Bytes
c97b1b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
document.addEventListener('DOMContentLoaded', function() {
    // Initialize GSAP animations
    gsap.registerPlugin(ScrollTrigger);
    
    // Animate doodle elements on scroll
    gsap.utils.toArray('[data-scroll]').forEach(element => {
        gsap.from(element, {
            scrollTrigger: {
                trigger: element,
                start: "top 80%",
                toggleActions: "play none none none"
            },
            y: 50,
            opacity: 0,
            duration: 1,
            ease: "power3.out"
        });
    });
    
    // Animate radial progress bars
    gsap.utils.toArray('.radial-progress').forEach(progress => {
        const value = progress.getAttribute('data-value') || progress.style.getPropertyValue('--value');
        gsap.to(progress, {
            '--value': value,
            duration: 2,
            ease: "elastic.out(1, 0.5)",
            scrollTrigger: {
                trigger: progress,
                start: "top 80%",
                toggleActions: "play none none none"
            }
        });
    });
    
    // Floating animation for doodle elements
    const doodles = document.querySelectorAll('.doodle');
    doodles.forEach((doodle, index) => {
        gsap.to(doodle, {
            y: index % 2 === 0 ? -20 : 20,
            duration: 3 + Math.random() * 2,
            repeat: -1,
            yoyo: true,
            ease: "sine.inOut"
        });
    });
    
    // Certificate hover effects
    const certificates = document.querySelectorAll('.bg-white.rounded-xl');
    certificates.forEach(cert => {
        cert.addEventListener('mouseenter', () => {
            gsap.to(cert.querySelector('i'), {
                rotation: 360,
                duration: 0.8,
                ease: "back.out"
            });
        });
    });
    
    // Smooth scrolling for anchor links
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function(e) {
            e.preventDefault();
            const target = document.querySelector(this.getAttribute('href'));
            if (target) {
                gsap.to(window, {
                    duration: 1,
                    scrollTo: target,
                    ease: "power2.inOut"
                });
            }
        });
    });
    
    // Form submission handling
    const contactForm = document.querySelector('form');
    if (contactForm) {
        contactForm.addEventListener('submit', function(e) {
            e.preventDefault();
            const submitBtn = this.querySelector('button[type="submit"]');
            const originalText = submitBtn.innerHTML;
            
            submitBtn.innerHTML = 'Sending...';
            submitBtn.disabled = true;
            
            // Simulate form submission
            setTimeout(() => {
                submitBtn.innerHTML = 'Message Sent!';
                gsap.to(submitBtn, {
                    backgroundColor: "#10b981",
                    duration: 0.5
                });
                
                // Reset form after 2 seconds
                setTimeout(() => {
                    this.reset();
                    submitBtn.innerHTML = originalText;
                    submitBtn.disabled = false;
                    gsap.to(submitBtn, {
                        backgroundColor: "#4f46e5",
                        duration: 0.5
                    });
                }, 2000);
            }, 1500);
        });
    }
});