// Smooth scrolling functionality for clients 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 Testimonios" button const verTestimoniosBtn = document.querySelector('a[href="#testimonios"]'); if (verTestimoniosBtn) { verTestimoniosBtn.addEventListener('click', function(event) { event.preventDefault(); const targetSection = document.getElementById('testimonios'); 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 verTestimoniosBtn = document.querySelector('a[href="#testimonios"]'); if (verTestimoniosBtn) { // Create a new element to replace the old one (removes all event listeners) const newBtn = verTestimoniosBtn.cloneNode(true); verTestimoniosBtn.parentNode.replaceChild(newBtn, verTestimoniosBtn); } } // Export functions export { init, teardown };