class CustomNavbar extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = `
`; // Add GSAP animations for text reveal const navItems = this.shadowRoot.querySelectorAll('.nav-item'); navItems.forEach((item, index) => { const text = item.querySelector('.nav-text'); item.addEventListener('mouseenter', () => { gsap.to(text, { opacity: 1, x: 0, duration: 0.3, ease: 'power2.out' }); // Animate each character const chars = text.textContent.split(''); text.textContent = ''; chars.forEach((char, i) => { const span = document.createElement('span'); span.textContent = char; span.style.display = 'inline-block'; span.style.opacity = '0'; span.style.transform = 'translateX(10px)'; text.appendChild(span); gsap.to(span, { opacity: 1, x: 0, duration: 0.1, delay: i * 0.03, ease: 'power2.out' }); }); }); item.addEventListener('mouseleave', () => { const spans = text.querySelectorAll('span'); gsap.to(spans, { opacity: 0, x: 10, duration: 0.2, ease: 'power2.in', onComplete: () => { text.textContent = text.querySelector('span') ? text.textContent : text.textContent; } }); gsap.to(text, { opacity: 0, x: 20, duration: 0.3, delay: 0.1, ease: 'power2.in' }); }); // Add click handler to scroll to section item.addEventListener('click', () => { const sections = ['about', 'work', 'reviews', 'contact', 'discourse.html']; if (index < sections.length) { document.getElementById(sections[index]).scrollIntoView({ behavior: 'smooth' }); } }); }); } } customElements.define('custom-navbar', CustomNavbar);