Spaces:
Running
Running
| 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); |