// Smooth scrolling functionality for services page function handleSmoothScroll(event) { const target = event.target.closest('a[href^="#"]'); if (!target) return; const href = target.getAttribute('href'); if (!href || href === '#') return; event.preventDefault(); const targetElement = document.querySelector(href); if (targetElement) { targetElement.scrollIntoView({ behavior: 'smooth', block: 'start' }); } } // Initialize smooth scrolling function init() { // Add smooth scrolling to all anchor links document.addEventListener('click', handleSmoothScroll); // Special handling for "Ver Servicios" button const verServiciosBtn = document.querySelector('a[href="#servicios-detalle"]'); if (verServiciosBtn) { verServiciosBtn.addEventListener('click', function(event) { event.preventDefault(); const targetSection = document.getElementById('servicios-detalle'); if (targetSection) { // Add a slight delay for better UX setTimeout(() => { targetSection.scrollIntoView({ behavior: 'smooth', block: 'start' }); }, 100); } }); } } // Cleanup function function teardown() { document.removeEventListener('click', handleSmoothScroll); const verServiciosBtn = document.querySelector('a[href="#servicios-detalle"]'); if (verServiciosBtn) { // Create a new element to replace the old one (removes all event listeners) const newBtn = verServiciosBtn.cloneNode(true); verServiciosBtn.parentNode.replaceChild(newBtn, verServiciosBtn); } } // Export functions export { init, teardown };