|
|
| |
| document.addEventListener('click', function(e) { |
| if (e.target.matches('a[href^="#"]')) { |
| e.preventDefault(); |
| const target = document.querySelector(e.target.getAttribute('href')); |
| if (target) { |
| target.scrollIntoView({ behavior: 'smooth' }); |
| } |
| } |
| }); |
|
|
| |
| const animateOnScroll = () => { |
| const elements = document.querySelectorAll('.animate'); |
| const observer = new IntersectionObserver((entries) => { |
| entries.forEach(entry => { |
| if (entry.isIntersecting) { |
| entry.target.classList.add('animate-visible'); |
| } |
| }); |
| }, { threshold: 0.1 }); |
|
|
| elements.forEach(el => observer.observe(el)); |
| }; |
|
|
| |
| const setupMobileMenu = () => { |
| const menuBtn = document.querySelector('.mobile-menu-btn'); |
| const mobileMenu = document.querySelector('.mobile-menu'); |
|
|
| if (menuBtn && mobileMenu) { |
| menuBtn.addEventListener('click', () => { |
| const isOpen = mobileMenu.style.display === 'flex'; |
| mobileMenu.style.display = isOpen ? 'none' : 'flex'; |
| }); |
| } |
| }; |
|
|
| |
| document.addEventListener('DOMContentLoaded', () => { |
| animateOnScroll(); |
| setupMobileMenu(); |
| }); |
|
|
|
|