Spaces:
Running
Running
File size: 2,223 Bytes
7ebc062 | 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 | 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); |