File size: 3,000 Bytes
ac4b9d7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | document.addEventListener('DOMContentLoaded', () => {
// Mobile Menu Toggle
const menuBtn = document.getElementById('menu-btn');
const mobileMenu = document.getElementById('mobile-menu');
menuBtn.addEventListener('click', () => {
if (mobileMenu.classList.contains('-translate-y-[150%]')) {
mobileMenu.classList.remove('-translate-y-[150%]');
mobileMenu.classList.add('translate-y-0');
} else {
mobileMenu.classList.add('-translate-y-[150%]');
mobileMenu.classList.remove('translate-y-0');
}
});
// Close mobile menu when clicking a link
const mobileLinks = mobileMenu.querySelectorAll('a');
mobileLinks.forEach(link => {
link.addEventListener('click', () => {
mobileMenu.classList.add('-translate-y-[150%]');
mobileMenu.classList.remove('translate-y-0');
});
});
// Navbar Scroll Effect
const navbar = document.getElementById('navbar');
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.classList.add('shadow-md');
navbar.classList.remove('shadow-sm');
} else {
navbar.classList.remove('shadow-md');
navbar.classList.add('shadow-sm');
}
});
// Scroll Reveal Animation
const reveals = document.querySelectorAll('.reveal');
const revealOnScroll = () => {
const windowHeight = window.innerHeight;
const elementVisible = 100;
reveals.forEach((reveal) => {
const elementTop = reveal.getBoundingClientRect().top;
if (elementTop < windowHeight - elementVisible) {
reveal.classList.add('active');
}
});
};
window.addEventListener('scroll', revealOnScroll);
// Trigger once on load
revealOnScroll();
// Simple Cart Interaction (Visual only)
const cartButtons = document.querySelectorAll('button i[data-feather="shopping-bag"]');
cartButtons.forEach(btn => {
btn.addEventListener('click', function() {
const card = this.closest('.bg-white');
card.classList.add('scale-95');
setTimeout(() => {
card.classList.remove('scale-95');
}, 150);
// Update cart count visual
const cartCount = document.querySelector('.bg-secondary.text-white.text-xs');
if(cartCount) {
let currentCount = parseInt(cartCount.innerText);
cartCount.innerText = currentCount + 1;
// Add simple bounce animation to cart icon
const cartIcon = document.querySelector('.relative.p-2 i[data-feather="shopping-cart"]');
cartIcon.parentElement.classList.add('scale-125');
setTimeout(() => {
cartIcon.parentElement.classList.remove('scale-125');
}, 200);
}
});
});
}); |