File size: 1,940 Bytes
6ee6051
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
class FloatingParticles extends HTMLElement {
    connectedCallback() {
        this.attachShadow({ mode: 'open' });
        this.shadowRoot.innerHTML = `
            <style>
                .particle {
                    position: absolute;
                    width: 4px;
                    height: 4px;
                    background: rgba(59, 130, 246, 0.6);
                    border-radius: 50%;
                    pointer-events: none;
                }
                
                @keyframes float-particle {
                    0% {
                        transform: translateY(100vh) rotate(0deg);
                        opacity: 0;
                    }
                    10% {
                        opacity: 1;
                    }
                    90% {
                        opacity: 1;
                    }
                    100% {
                        transform: translateY(-100px) rotate(360deg);
                        opacity: 0;
                    }
                }
            </style>
            <div id="particles-container"></div>
        `;
        
        this.createParticles();
    }
    
    createParticles() {
        const container = this.shadowRoot.getElementById('particles-container');
        const particleCount = 15;
        
        for (let i = 0; i < particleCount; i++) {
            const particle = document.createElement('div');
            particle.className = 'particle';
            
            // Random properties
            const left = Math.random() * 100;
            const delay = Math.random() * 20;
            const duration = 15 + Math.random() * 10;
            
            particle.style.left = `${left}%`;
            particle.style.animation = `float-particle ${duration}s linear ${delay}s infinite`;
            
            container.appendChild(particle);
        }
    }
}

customElements.define('floating-particles', FloatingParticles);