Spaces:
Running
Running
| // Smooth scrolling for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function (e) { | |
| e.preventDefault(); | |
| document.querySelector(this.getAttribute('href')).scrollIntoView({ | |
| behavior: 'smooth' | |
| }); | |
| }); | |
| }); | |
| // Animate menu items when they come into view | |
| const observer = new IntersectionObserver((entries) => { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| entry.target.classList.add('menu-item'); | |
| } | |
| }); | |
| }, {threshold: 0.1}); | |
| document.querySelectorAll('#menu li').forEach(item => { | |
| observer.observe(item); | |
| }); | |
| // Simple cart functionality | |
| document.addEventListener('DOMContentLoaded', () => { | |
| const cartCount = document.createElement('span'); | |
| cartCount.id = 'cart-count'; | |
| cartCount.className = 'absolute -top-2 -right-2 bg-amber-600 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center'; | |
| cartCount.textContent = '0'; | |
| const cartIcon = document.querySelector('[data-feather="shopping-cart"]').parentNode; | |
| cartIcon.appendChild(cartCount); | |
| cartIcon.classList.add('relative'); | |
| }); |