| |
| function closePromoBanner() { |
| const banner = document.getElementById('promo-banner'); |
| banner.style.maxHeight = banner.offsetHeight + 'px'; |
| requestAnimationFrame(() => { |
| banner.style.maxHeight = '0'; |
| banner.style.padding = '0'; |
| banner.style.opacity = '0'; |
| banner.style.overflow = 'hidden'; |
| }); |
| setTimeout(() => { |
| banner.style.display = 'none'; |
| }, 400); |
| } |
|
|
| |
| const mobileMenuBtn = document.getElementById('mobile-menu-btn'); |
| const mobileMenu = document.getElementById('mobile-menu'); |
| let isMenuOpen = false; |
|
|
| mobileMenuBtn.addEventListener('click', () => { |
| isMenuOpen = !isMenuOpen; |
| if (isMenuOpen) { |
| mobileMenu.classList.add('open'); |
| mobileMenuBtn.innerHTML = '<i data-lucide="x" class="w-6 h-6"></i>'; |
| } else { |
| mobileMenu.classList.remove('open'); |
| mobileMenuBtn.innerHTML = '<i data-lucide="menu" class="w-6 h-6"></i>'; |
| } |
| lucide.createIcons(); |
| }); |
|
|
| |
| mobileMenu.querySelectorAll('a').forEach(link => { |
| link.addEventListener('click', () => { |
| isMenuOpen = false; |
| mobileMenu.classList.remove('open'); |
| mobileMenuBtn.innerHTML = '<i data-lucide="menu" class="w-6 h-6"></i>'; |
| lucide.createIcons(); |
| }); |
| }); |
|
|
| |
| const header = document.getElementById('header'); |
| window.addEventListener('scroll', () => { |
| if (window.scrollY > 50) { |
| header.classList.add('scrolled'); |
| } else { |
| header.classList.remove('scrolled'); |
| } |
| }); |
|
|
| |
| const coupon = document.getElementById('coupon-float'); |
| let couponDismissed = false; |
|
|
| function showCoupon() { |
| if (!couponDismissed) { |
| setTimeout(() => { |
| coupon.style.display = 'block'; |
| coupon.style.opacity = '1'; |
| coupon.style.transform = 'translateY(0)'; |
| }, 4000); |
| } |
| } |
|
|
| function closeCoupon() { |
| couponDismissed = true; |
| coupon.style.opacity = '0'; |
| coupon.style.transform = 'translateY(20px)'; |
| setTimeout(() => { |
| coupon.style.display = 'none'; |
| }, 400); |
| } |
|
|
| |
| let couponReappear = false; |
| const proceduresSection = document.getElementById('procedures'); |
|
|
| const observer = new IntersectionObserver((entries) => { |
| entries.forEach(entry => { |
| if (entry.isIntersecting && !couponReappear) { |
| couponReappear = true; |
| couponDismissed = false; |
| showCoupon(); |
| } |
| }); |
| }, { threshold: 0.3 }); |
|
|
| if (proceduresSection) { |
| observer.observe(proceduresSection); |
| } |
|
|
| |
| showCoupon(); |
|
|
| |
| const track = document.getElementById('testimonial-track'); |
| const prevBtn = document.getElementById('testimonial-prev'); |
| const nextBtn = document.getElementById('testimonial-next'); |
|
|
| if (track && prevBtn && nextBtn) { |
| const scrollAmount = 370; |
|
|
| prevBtn.addEventListener('click', () => { |
| track.scrollBy({ left: -scrollAmount, behavior: 'smooth' }); |
| }); |
|
|
| nextBtn.addEventListener('click', () => { |
| track.scrollBy({ left: scrollAmount, behavior: 'smooth' }); |
| }); |
|
|
| |
| let autoScrollInterval = setInterval(() => { |
| const maxScroll = track.scrollWidth - track.clientWidth; |
| if (track.scrollLeft >= maxScroll - 10) { |
| track.scrollTo({ left: 0, behavior: 'smooth' }); |
| } else { |
| track.scrollBy({ left: scrollAmount, behavior: 'smooth' }); |
| } |
| }, 5000); |
|
|
| |
| track.addEventListener('mouseenter', () => clearInterval(autoScrollInterval)); |
| track.addEventListener('mouseleave', () => { |
| autoScrollInterval = setInterval(() => { |
| const maxScroll = track.scrollWidth - track.clientWidth; |
| if (track.scrollLeft >= maxScroll - 10) { |
| track.scrollTo({ left: 0, behavior: 'smooth' }); |
| } else { |
| track.scrollBy({ left: scrollAmount, behavior: 'smooth' }); |
| } |
| }, 5000); |
| }); |
| } |
|
|
| |
| const contactForm = document.getElementById('contact-form'); |
| if (contactForm) { |
| contactForm.addEventListener('submit', (e) => { |
| e.preventDefault(); |
|
|
| const submitBtn = contactForm.querySelector('button[type="submit"]'); |
| const originalText = submitBtn.innerHTML; |
|
|
| |
| submitBtn.innerHTML = '<span class="animate-spin inline-block w-5 h-5 border-2 border-gray-900 border-t-transparent rounded-full"></span> Enviando...'; |
| submitBtn.disabled = true; |
|
|
| setTimeout(() => { |
| submitBtn.innerHTML = '<i data-lucide="check" class="w-5 h-5"></i> Mensagem Enviada!'; |
| submitBtn.classList.add('bg-green-400', 'hover:bg-green-400'); |
| lucide.createIcons(); |
|
|
| |
| contactForm.reset(); |
|
|
| |
| setTimeout(() => { |
| submitBtn.innerHTML = originalText; |
| submitBtn.classList.remove('bg-green-400', 'hover:bg-green-400'); |
| submitBtn.disabled = false; |
| lucide.createIcons(); |
| }, 3000); |
| }, 1500); |
| }); |
| } |
|
|
| |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { |
| anchor.addEventListener('click', function(e) { |
| e.preventDefault(); |
| const target = document.querySelector(this.getAttribute('href')); |
| if (target) { |
| const headerOffset = 80; |
| const elementPosition = target.getBoundingClientRect().top; |
| const offsetPosition = elementPosition + window.pageYOffset - headerOffset; |
|
|
| window.scrollTo({ |
| top: offsetPosition, |
| behavior: 'smooth' |
| }); |
| } |
| }); |
| }); |
|
|
| |
| const fadeElements = document.querySelectorAll('.fade-in-on-scroll'); |
|
|
| const fadeObserver = new IntersectionObserver((entries) => { |
| entries.forEach(entry => { |
| if (entry.isIntersecting) { |
| entry.target.classList.add('visible'); |
| fadeObserver.unobserve(entry.target); |
| } |
| }); |
| }, { |
| threshold: 0.1, |
| rootMargin: '0px 0px -50px 0px' |
| }); |
|
|
| fadeElements.forEach(el => fadeObserver.observe(el)); |
|
|
| |
| const whatsappBtn = document.querySelector('a[href*="wa.me"]'); |
| if (whatsappBtn) { |
| window.addEventListener('scroll', () => { |
| const scrollPercent = window.scrollY / (document.documentElement.scrollHeight - window.innerHeight); |
| if (scrollPercent > 0.3) { |
| whatsappBtn.classList.add('animate-pulse-soft'); |
| } |
| }); |
| } |
|
|
| |
| const sections = document.querySelectorAll('section[id]'); |
| const navLinks = document.querySelectorAll('header nav a[href^="#"]'); |
|
|
| window.addEventListener('scroll', () => { |
| let current = ''; |
| sections.forEach(section => { |
| const sectionTop = section.offsetTop - 100; |
| if (window.scrollY >= sectionTop) { |
| current = section.getAttribute('id'); |
| } |
| }); |
|
|
| navLinks.forEach(link => { |
| link.classList.remove('text-olive'); |
| if (link.getAttribute('href') === '#' + current) { |
| link.classList.add('text-olive'); |
| } |
| }); |
| }); |
|
|
| |
| document.addEventListener('DOMContentLoaded', () => { |
| console.log('✨ Zays Clinic - Site carregado com sucesso!'); |
| console.log('💫 Revele sua melhor versão.'); |
| }); |