Download script.js from bkpradhan8/mining-marvels-unleashed: direct link, hf CLI and curl.
- Browser
- Download file 3.69 kB
-
https://huggingface.co/spaces/bkpradhan8/mining-marvels-unleashed/resolve/main/script.js
- Command line
-
hf download hf://spaces/bkpradhan8/mining-marvels-unleashed/script.js
-
curl -L -o script.js https://huggingface.co/spaces/bkpradhan8/mining-marvels-unleashed/resolve/main/script.js
3.69 kB
| // Smooth scrolling for anchor links | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Smooth scroll for anchor links | |
| const anchorLinks = document.querySelectorAll('a[href^="#"]'); | |
| anchorLinks.forEach(link => { | |
| link.addEventListener('click', function(e) { | |
| e.preventDefault(); | |
| const targetId = this.getAttribute('href'); | |
| const targetElement = document.querySelector(targetId); | |
| if (targetElement) { | |
| targetElement.scrollIntoView({ | |
| behavior: 'smooth', | |
| block: 'start' | |
| }); | |
| } | |
| }); | |
| }); | |
| // Counter animation for stats | |
| const counters = document.querySelectorAll('.counter-number'); | |
| const speed = 200; | |
| const animateCounter = (counter) => { | |
| const target = +counter.getAttribute('data-target'); | |
| const count = +counter.innerText; | |
| const increment = target / speed; | |
| if (count < target) { | |
| counter.innerText = Math.ceil(count + increment); | |
| setTimeout(() => animateCounter(counter), 1); | |
| } else { | |
| counter.innerText = target; | |
| } | |
| }; | |
| // Intersection Observer for counter animation | |
| const observer = new IntersectionObserver((entries) => { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| animateCounter(entry.target); | |
| } | |
| }); | |
| counters.forEach(counter => { | |
| observer.observe(counter); | |
| }); | |
| // Parallax effect for background elements | |
| window.addEventListener('scroll', function() { | |
| const scrolled = window.pageYOffset; | |
| const parallaxElements = document.querySelectorAll('.parallax'); | |
| parallaxElements.forEach(element => { | |
| const speed = element.getAttribute('data-speed') || 0.5; | |
| element.style.transform = `translateY(${scrolled * speed}px)`; | |
| }); | |
| // Mobile menu toggle (for future implementation) | |
| window.toggleMobileMenu = function() { | |
| const mobileMenu = document.getElementById('mobileMenu'); | |
| mobileMenu.classList.toggle('hidden'); | |
| }; | |
| // Add hover effects to service cards | |
| const serviceCards = document.querySelectorAll('.service-card'); | |
| serviceCards.forEach(card => { | |
| card.addEventListener('mouseenter', function() { | |
| this.style.transform = 'translateY(-8px)'; | |
| this.style.boxShadow = '0 25px 50px -12px rgba(0, 0, 0, 0.25)'; | |
| }); | |
| card.addEventListener('mouseleave', function() { | |
| this.style.transform = 'translateY(0)'; | |
| this.style.boxShadow = '0 10px 15px -3px rgba(0, 0, 0, 0.1)'; | |
| }); | |
| }); | |
| // Form handling (for contact forms) | |
| const contactForms = document.querySelectorAll('.contact-form'); | |
| contactForms.forEach(form => { | |
| form.addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| // Add form submission logic here | |
| alert('Thank you for your message! We will get back to you soon.'); | |
| form.reset(); | |
| }); | |
| }); | |
| // Lazy loading for images | |
| const imageObserver = new IntersectionObserver((entries, observer) => { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| const img = entry.target; | |
| img.src = img.getAttribute('data-src'); | |
| imageObserver.unobserve(img); | |
| } | |
| }); | |
| }); | |
| document.querySelectorAll('img[data-src]').forEach(img => { | |
| imageObserver.observe(img); | |
| }); | |
| // Add loading animation | |
| window.addEventListener('load', function() { | |
| document.body.classList.add('loaded'); | |
| }); | |
| }); |