// JavaScript for Gazala.co.id Premium Design // Smooth scroll const navLinks = document.querySelectorAll('a[href^="#"]'); navLinks.forEach(link => { link.addEventListener('click', e => { e.preventDefault(); document.querySelector(link.getAttribute('href')).scrollIntoView({ behavior: 'smooth' }); }); }); // Sticky navbar shadow const header = document.querySelector('header'); window.addEventListener('scroll', () => { if (window.scrollY > 10) { header.classList.add('shadow'); } else { header.classList.remove('shadow'); } }); // Mobile menu toggle const menuBtn = document.querySelector('#menu-btn'); const mobileMenu = document.querySelector('#mobile-menu'); menuBtn.addEventListener('click', () => { mobileMenu.classList.toggle('hidden'); }); // Reveal on scroll const reveals = document.querySelectorAll('.reveal'); const revealOnScroll = () => { for (let el of reveals) { const rect = el.getBoundingClientRect(); if (rect.top < window.innerHeight - 80) { el.classList.add('active'); } } }; window.addEventListener('scroll', revealOnScroll); revealOnScroll(); // Hero slider (auto-fade) let slideIndex = 0; const slides = document.querySelectorAll('.hero-slide'); const nextSlide = () => { slides.forEach(slide => slide.classList.remove('show')); slideIndex = (slideIndex + 1) % slides.length; slides[slideIndex].classList.add('show'); }; setInterval(nextSlide, 6000); // Counter animation const counters = document.querySelectorAll('.counter'); const runCounters = () => { counters.forEach(counter => { const update = () => { const target = +counter.getAttribute('data-target'); const current = +counter.innerText; const increment = target / 120; if (current < target) { counter.innerText = Math.ceil(current + increment); setTimeout(update, 20); } else { counter.innerText = target; } }; update(); }); }; // Start counters when visible const counterSection = document.querySelector('#counter-section'); let counterStarted = false; window.addEventListener('scroll', () => { const rect = counterSection.getBoundingClientRect(); if (!counterStarted && rect.top < window.innerHeight - 50) { counterStarted = true; runCounters(); } });

Main Menu