Download script.js from AlanAgb/dollstore: direct link, hf CLI and curl.
- Browser
- Download file 3 kB
-
https://huggingface.co/spaces/AlanAgb/dollstore/resolve/main/script.js
- Command line
-
hf download hf://spaces/AlanAgb/dollstore/script.js
-
curl -L -o script.js https://huggingface.co/spaces/AlanAgb/dollstore/resolve/main/script.js
3 kB
| 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); | |
| } | |
| }); | |
| }); | |
| }); |