|
|
document.addEventListener('DOMContentLoaded', function() { |
|
|
|
|
|
document.addEventListener('click', function(event) { |
|
|
if (event.target.closest('.mobile-menu-btn')) { |
|
|
const navLinks = document.querySelector('custom-navbar').shadowRoot.querySelector('.nav-links'); |
|
|
navLinks.style.display = navLinks.style.display === 'flex' ? 'none' : 'flex'; |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
document.querySelectorAll('a[href^="#"]').forEach(anchor => { |
|
|
anchor.addEventListener('click', function(e) { |
|
|
e.preventDefault(); |
|
|
const targetId = this.getAttribute('href'); |
|
|
if (targetId === '#') return; |
|
|
|
|
|
const targetElement = document.querySelector(targetId); |
|
|
if (targetElement) { |
|
|
window.scrollTo({ |
|
|
top: targetElement.offsetTop - 100, |
|
|
behavior: 'smooth' |
|
|
}); |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const contactForm = document.querySelector('form'); |
|
|
if (contactForm) { |
|
|
contactForm.addEventListener('submit', function(e) { |
|
|
e.preventDefault(); |
|
|
alert('Gracias por tu mensaje. Nos pondremos en contacto contigo pronto.'); |
|
|
this.reset(); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
const animateOnScroll = function() { |
|
|
const elements = document.querySelectorAll('.service-card, .testimonial-card'); |
|
|
|
|
|
elements.forEach(element => { |
|
|
const elementPosition = element.getBoundingClientRect().top; |
|
|
const screenPosition = window.innerHeight / 1.2; |
|
|
|
|
|
if (elementPosition < screenPosition) { |
|
|
element.style.opacity = '1'; |
|
|
element.style.transform = 'translateY(0)'; |
|
|
} |
|
|
}); |
|
|
}; |
|
|
|
|
|
|
|
|
document.querySelectorAll('.service-card, .testimonial-card').forEach(element => { |
|
|
element.style.opacity = '0'; |
|
|
element.style.transform = 'translateY(20px)'; |
|
|
element.style.transition = 'opacity 0.6s ease, transform 0.6s ease'; |
|
|
}); |
|
|
|
|
|
window.addEventListener('scroll', animateOnScroll); |
|
|
animateOnScroll(); |
|
|
}); |