Spaces:
Running
Running
File size: 1,078 Bytes
351ea5d 846057f 6c7709a 351ea5d 846057f 351ea5d 846057f | 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 |
class GlowEffect extends HTMLElement {
connectedCallback() {
this.style.position = 'relative';
this.style.display = 'inline-block';
const glow = document.createElement('div');
glow.style.position = 'absolute';
glow.style.top = '0';
glow.style.left = '0';
glow.style.right = '0';
glow.style.bottom = '0';
glow.style.borderRadius = 'inherit';
glow.style.background = `radial-gradient(circle at center,
rgba(${this.getAttribute('r') || '139'}, ${this.getAttribute('g') || '92'}, ${this.getAttribute('b') || '246'}, 0.5) 0%,
transparent 80%)`;
glow.style.pointerEvents = 'none';
glow.style.opacity = '0';
glow.style.transition = 'opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1)';
glow.style.filter = 'blur(12px)';
glow.style.zIndex = '-1';
this.appendChild(glow);
this.addEventListener('mouseenter', () => {
glow.style.opacity = '1';
});
this.addEventListener('mouseleave', () => {
glow.style.opacity = '0';
});
}
}
customElements.define('glow-effect', GlowEffect); |