Spaces:
Running
Running
Download script.js from arivaknin10/digitaleo: direct link, hf CLI and curl.
- Browser
- Download file 6.34 kB
-
https://huggingface.co/spaces/arivaknin10/digitaleo/resolve/main/script.js
- Command line
-
hf download hf://spaces/arivaknin10/digitaleo/script.js
-
curl -L -o script.js https://huggingface.co/spaces/arivaknin10/digitaleo/resolve/main/script.js
6.34 kB
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize Feather Icons | |
| feather.replace(); | |
| // Scroll Reveal Animation | |
| const revealElements = document.querySelectorAll('.reveal'); | |
| const revealOnScroll = () => { | |
| const windowHeight = window.innerHeight; | |
| const elementVisible = 150; | |
| revealElements.forEach((element) => { | |
| const elementTop = element.getBoundingClientRect().top; | |
| if (elementTop < windowHeight - elementVisible) { | |
| element.classList.add('active'); | |
| } | |
| }); | |
| }; | |
| window.addEventListener('scroll', revealOnScroll); | |
| revealOnScroll(); // Check on load | |
| // Smooth Scroll for Anchor Links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function(e) { | |
| e.preventDefault(); | |
| const target = document.querySelector(this.getAttribute('href')); | |
| if (target) { | |
| target.scrollIntoView({ | |
| behavior: 'smooth', | |
| block: 'start' | |
| }); | |
| } | |
| }); | |
| }); | |
| // Navbar Background on Scroll | |
| const navbar = document.querySelector('lion-navbar'); | |
| let lastScroll = 0; | |
| window.addEventListener('scroll', () => { | |
| const currentScroll = window.pageYOffset; | |
| if (currentScroll > 100) { | |
| navbar?.shadowRoot?.querySelector('nav')?.classList.add('bg-night-900/95', 'backdrop-blur-md', 'shadow-lg'); | |
| } else { | |
| navbar?.shadowRoot?.querySelector('nav')?.classList.remove('bg-night-900/95', 'backdrop-blur-md', 'shadow-lg'); | |
| } | |
| lastScroll = currentScroll; | |
| }); | |
| // Parallax Effect for Hero | |
| const heroSection = document.querySelector('section:first-of-type'); | |
| if (heroSection) { | |
| window.addEventListener('scroll', () => { | |
| const scrolled = window.pageYOffset; | |
| const parallax = heroSection.querySelector('.absolute'); | |
| if (parallax) { | |
| parallax.style.transform = `translateY(${scrolled * 0.5}px)`; | |
| } | |
| }); | |
| } | |
| // Form Submission Handler | |
| const contactForm = document.querySelector('form'); | |
| if (contactForm) { | |
| contactForm.addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| // Show success message | |
| const btn = this.querySelector('button[type="submit"]'); | |
| const originalText = btn.innerHTML; | |
| btn.innerHTML = '<i data-feather="check" class="w-5 h-5"></i> 讛讛讜讚注讛 谞砖诇讞讛!'; | |
| btn.classList.remove('bg-lion-500'); | |
| btn.classList.add('bg-green-500'); | |
| feather.replace(); | |
| setTimeout(() => { | |
| btn.innerHTML = originalText; | |
| btn.classList.add('bg-lion-500'); | |
| btn.classList.remove('bg-green-500'); | |
| this.reset(); | |
| feather.replace(); | |
| }, 3000); | |
| }); | |
| } | |
| // Intersection Observer for Counter Animation | |
| const observerOptions = { | |
| threshold: 0.5, | |
| rootMargin: "0px" | |
| }; | |
| const observer = new IntersectionObserver((entries) => { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| entry.target.classList.add('animate'); | |
| } | |
| }); | |
| }, observerOptions); | |
| document.querySelectorAll('.counter').forEach(counter => { | |
| observer.observe(counter); | |
| }); | |
| // Mobile Menu Toggle | |
| const setupMobileMenu = () => { | |
| const mobileBtn = document.querySelector('.mobile-menu-btn'); | |
| const mobileMenu = document.querySelector('.mobile-menu'); | |
| if (mobileBtn && mobileMenu) { | |
| mobileBtn.addEventListener('click', () => { | |
| mobileMenu.classList.toggle('hidden'); | |
| mobileMenu.classList.toggle('flex'); | |
| }); | |
| } | |
| }; | |
| // Call setup after a short delay to ensure Shadow DOM is ready | |
| setTimeout(setupMobileMenu, 100); | |
| // Add hover effects to service cards | |
| document.querySelectorAll('service-card').forEach(card => { | |
| card.addEventListener('mouseenter', function() { | |
| this.style.transform = 'translateY(-10px)'; | |
| }); | |
| card.addEventListener('mouseleave', function() { | |
| this.style.transform = 'translateY(0)'; | |
| }); | |
| }); | |
| // Typing Effect for Hero (Optional enhancement) | |
| const typeWriter = (element, text, speed = 100) => { | |
| let i = 0; | |
| element.innerHTML = ''; | |
| const type = () => { | |
| if (i < text.length) { | |
| element.innerHTML += text.charAt(i); | |
| i++; | |
| setTimeout(type, speed); | |
| } | |
| }; | |
| type(); | |
| }; | |
| // Initialize tooltips or other interactive elements | |
| const initTooltips = () => { | |
| const tooltipTriggers = document.querySelectorAll('[data-tooltip]'); | |
| tooltipTriggers.forEach(trigger => { | |
| trigger.addEventListener('mouseenter', (e) => { | |
| const tooltip = document.createElement('div'); | |
| tooltip.className = 'fixed bg-night-800 text-white px-3 py-2 rounded-lg text-sm z-50 border border-lion-500/30 shadow-xl'; | |
| tooltip.textContent = e.target.dataset.tooltip; | |
| tooltip.id = 'active-tooltip'; | |
| document.body.appendChild(tooltip); | |
| const rect = e.target.getBoundingClientRect(); | |
| tooltip.style.top = `${rect.top - tooltip.offsetHeight - 10}px`; | |
| tooltip.style.left = `${rect.left + (rect.width / 2) - (tooltip.offsetWidth / 2)}px`; | |
| }); | |
| trigger.addEventListener('mouseleave', () => { | |
| const tooltip = document.getElementById('active-tooltip'); | |
| if (tooltip) tooltip.remove(); | |
| }); | |
| }); | |
| }; | |
| initTooltips(); | |
| }); | |
| // Lion Roar Sound Effect (Visual feedback only) | |
| function triggerRoar(element) { | |
| element.classList.add('scale-110'); | |
| setTimeout(() => { | |
| element.classList.remove('scale-110'); | |
| }, 200); | |
| } |