// دراجتك - Landing Page Interactions // ---------- Navbar Scroll Effect ---------- const navbar = document.getElementById('navbar'); window.addEventListener('scroll', function() { if (window.scrollY > 50) { navbar.classList.add('scrolled'); } else { navbar.classList.remove('scrolled'); } }); // ---------- Mobile Menu Toggle ---------- function toggleMenu() { document.getElementById('navLinks').classList.toggle('show'); } document.querySelectorAll('.nav-links a').forEach(function(link) { link.addEventListener('click', function() { document.getElementById('navLinks').classList.remove('show'); }); }); // ---------- Scroll Animations (Intersection Observer) ---------- const observerOptions = { threshold: 0.15, rootMargin: '0px 0px -40px 0px' }; const observer = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { if (entry.isIntersecting) { entry.target.classList.add('visible'); observer.unobserve(entry.target); } }); }, observerOptions); document.querySelectorAll('.animate').forEach(function(el) { observer.observe(el); }); // ---------- Counter Animation ---------- function animateCounters() { document.querySelectorAll('[data-count]').forEach(function(counter) { var target = parseInt(counter.getAttribute('data-count')); var current = 0; var increment = target / 40; var timer = setInterval(function() { current += increment; if (current >= target) { counter.textContent = '+' + target; clearInterval(timer); } else { counter.textContent = '+' + Math.floor(current); } }, 30); }); } // Trigger counter animation when stats card becomes visible var statsObserved = false; var statsObserver = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { if (entry.isIntersecting && !statsObserved) { statsObserved = true; animateCounters(); statsObserver.unobserve(entry.target); } }); }, { threshold: 0.5 }); var statsSection = document.querySelector('.stat-card'); if (statsSection) { statsObserver.observe(statsSection); } // ---------- Smooth Scroll for Anchor Links ---------- document.querySelectorAll('a[href^="#"]').forEach(function(anchor) { anchor.addEventListener('click', function(e) { e.preventDefault(); var target = document.querySelector(this.getAttribute('href')); if (target) { var offset = 80; var position = target.getBoundingClientRect().top + window.pageYOffset - offset; window.scrollTo({ top: position, behavior: 'smooth' }); } }); });