Download script.js from TomdoMin3/snav-ghost-browser-galaxy: direct link, hf CLI and curl.
- Browser
- Download file 2.11 kB
-
https://huggingface.co/spaces/TomdoMin3/snav-ghost-browser-galaxy/resolve/main/script.js
- Command line
-
hf download hf://spaces/TomdoMin3/snav-ghost-browser-galaxy/script.js
-
curl -L -o script.js https://huggingface.co/spaces/TomdoMin3/snav-ghost-browser-galaxy/resolve/main/script.js
2.11 kB
| // Mobile menu toggle functionality | |
| document.addEventListener('DOMContentLoaded', () => { | |
| const navbar = document.querySelector('custom-navbar'); | |
| if (!navbar) return; | |
| const shadow = navbar.shadowRoot; | |
| const mobileMenuButton = shadow.querySelector('button'); | |
| const mobileMenuLinks = shadow.querySelectorAll('.nav-link'); | |
| if (mobileMenuButton) { | |
| mobileMenuButton.addEventListener('click', () => { | |
| const menu = shadow.querySelector('.hidden.md\\:flex'); | |
| if (!menu) return; | |
| menu.classList.toggle('hidden'); | |
| menu.classList.toggle('flex'); | |
| menu.classList.toggle('flex-col'); | |
| menu.classList.toggle('absolute'); | |
| menu.classList.toggle('top-16'); | |
| menu.classList.toggle('left-0'); | |
| menu.classList.toggle('right-0'); | |
| menu.classList.toggle('bg-gray-900'); | |
| menu.classList.toggle('p-4'); | |
| menu.classList.toggle('space-y-4'); | |
| }); | |
| } | |
| // Close mobile menu when a link is clicked | |
| mobileMenuLinks.forEach(link => { | |
| link.addEventListener('click', () => { | |
| const menu = shadow.querySelector('.flex.flex-col'); | |
| if (menu) { | |
| menu.classList.add('hidden'); | |
| menu.classList.remove('flex'); | |
| } | |
| }); | |
| }); | |
| // Animate elements with delay | |
| document.querySelectorAll('.animate-fade-in').forEach((el, i) => { | |
| el.style.animationDelay = `${i * 0.2}s`; | |
| }); | |
| // Smooth scrolling for anchor links including FAB links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function(e) { | |
| const targetId = this.getAttribute('href'); | |
| if (targetId === '#') return; | |
| e.preventDefault(); | |
| const target = document.querySelector(targetId); | |
| if (target) { | |
| window.scrollTo({ | |
| top: target.offsetTop - 100, | |
| behavior: 'smooth' | |
| }); | |
| } | |
| }); | |
| }); | |
| }); |