// Initialize Lucide Icons lucide.createIcons(); // ======================== // Mobile Menu // ======================== const menuBtn = document.getElementById('menuBtn'); const closeMenuBtn = document.getElementById('closeMenu'); const mobileMenu = document.getElementById('mobileMenu'); const mobileOverlay = document.getElementById('mobileOverlay'); function openMobileMenu() { mobileMenu.classList.add('active'); mobileOverlay.classList.add('active'); document.body.style.overflow = 'hidden'; } function closeMobileMenu() { mobileMenu.classList.remove('active'); mobileOverlay.classList.remove('active'); document.body.style.overflow = ''; } menuBtn.addEventListener('click', openMobileMenu); closeMenuBtn.addEventListener('click', closeMobileMenu); mobileOverlay.addEventListener('click', closeMobileMenu); document.querySelectorAll('.mobile-link').forEach(link => { link.addEventListener('click', closeMobileMenu); }); // ======================== // Sticky Navbar // ======================== const navbar = document.getElementById('navbar'); window.addEventListener('scroll', () => { if (window.pageYOffset > 80) { navbar.classList.add('navbar-scrolled'); } else { navbar.classList.remove('navbar-scrolled'); } }); // ======================== // Scroll Reveal // ======================== const revealElements = document.querySelectorAll('.reveal, .reveal-left, .reveal-right'); const revealObserver = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('visible'); } }); }, { threshold: 0.1, rootMargin: '0px 0px -60px 0px' }); revealElements.forEach(el => revealObserver.observe(el)); // ======================== // Counter Animation (Impact Section) // ======================== function animateCounter(elementId, target, duration = 2000) { const element = document.getElementById(elementId); if (!element) return; const startTime = performance.now(); function update(currentTime) { const elapsed = currentTime - startTime; const progress = Math.min(elapsed / duration, 1); const eased = 1 - Math.pow(1 - progress, 3); const current = Math.floor(eased * target); element.textContent = current; if (progress < 1) { requestAnimationFrame(update); } } requestAnimationFrame(update); } const impactSection = document.getElementById('dampak'); let countersAnimated = false; const counterObserver = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting && !countersAnimated) { countersAnimated = true; animateCounter('statEfisiensi', 50); animateCounter('statAnggota', 40); animateCounter('statRealtime', 100); animateCounter('statSHU', 30); } }); }, { threshold: 0.3 }); if (impactSection) { counterObserver.observe(impactSection); } // ======================== // Smooth Scroll // ======================== document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function(e) { e.preventDefault(); const target = document.querySelector(this.getAttribute('href')); if (target) { const offsetTop = target.offsetTop - 80; window.scrollTo({ top: offsetTop, behavior: 'smooth' }); } }); });