Spaces:
Running
Running
| class FloatingElements extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| :host { | |
| display: block; | |
| position: fixed; | |
| top: 0; | |
| left: 0; | |
| width: 100%; | |
| height: 100%; | |
| pointer-events: none; | |
| z-index: -1; | |
| overflow: hidden; | |
| } | |
| .floating-element { | |
| position: absolute; | |
| border-radius: 50%; | |
| background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(16, 185, 129, 0.1)); | |
| filter: blur(20px); | |
| animation: float 20s infinite ease-in-out; | |
| } | |
| @keyframes float { | |
| 0%, 100% { transform: translate(0, 0) rotate(0deg); } | |
| 25% { transform: translate(100px, 50px) rotate(90deg); } | |
| 50% { transform: translate(50px, 100px) rotate(180deg); } | |
| 75% { transform: translate(-50px, 50px) rotate(270deg); } | |
| } | |
| </style> | |
| `; | |
| // Create floating elements | |
| this.createFloatingElements(); | |
| } | |
| createFloatingElements() { | |
| const colors = [ | |
| 'rgba(59, 130, 246, 0.15)', | |
| 'rgba(16, 185, 129, 0.15)', | |
| 'rgba(139, 92, 246, 0.15)', | |
| 'rgba(239, 68, 68, 0.15)', | |
| 'rgba(245, 158, 11, 0.15)' | |
| ]; | |
| for (let i = 0; i < 8; i++) { | |
| const element = document.createElement('div'); | |
| element.className = 'floating-element'; | |
| // Random properties | |
| const size = Math.random() * 300 + 100; | |
| const color = colors[Math.floor(Math.random() * colors.length)]; | |
| const left = Math.random() * 100; | |
| const top = Math.random() * 100; | |
| const delay = Math.random() * 20; | |
| const duration = 20 + Math.random() * 20; | |
| element.style.width = `${size}px`; | |
| element.style.height = `${size}px`; | |
| element.style.background = color; | |
| element.style.left = `${left}%`; | |
| element.style.top = `${top}%`; | |
| element.style.animationDelay = `${delay}s`; | |
| element.style.animationDuration = `${duration}s`; | |
| this.shadowRoot.appendChild(element); | |
| } | |
| } | |
| } | |
| customElements.define('floating-elements', FloatingElements); |