Spaces:
Running
Running
File size: 1,662 Bytes
97928d6 3f31db4 97928d6 | 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 |
// Main JavaScript file for shared functionality
document.addEventListener('DOMContentLoaded', function() {
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Sticky navbar with shadow on scroll
const navbar = document.querySelector('custom-navbar').shadowRoot.querySelector('.navbar');
window.addEventListener('scroll', () => {
if (window.scrollY > 10) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Mobile menu toggle (would need to be implemented in navbar component)
const mobileMenuButton = document.querySelector('custom-navbar').shadowRoot.querySelector('button.md\\:hidden');
const mobileMenu = document.createElement('div');
mobileMenu.className = 'mobile-menu';
['inicio', 'servicos', 'beneficios', 'sobre', 'contato'].forEach(id => {
const link = document.createElement('a');
link.href = `#${id}`;
link.className = 'nav-link text-white hover:text-[#22FFC4] py-2 px-4';
link.textContent = document.querySelector(`a[href="#${id}"]`).textContent;
mobileMenu.appendChild(link);
});
document.querySelector('custom-navbar').shadowRoot.appendChild(mobileMenu);
mobileMenuButton.addEventListener('click', () => {
mobileMenu.classList.toggle('active');
});
});
|