themaximsuper/hostale-hytale-server-hosting
0
1 2// Smooth scrolling for anchor links3document.querySelectorAll('a[href^="#"]').forEach(anchor => {4 anchor.addEventListener('click', function (e) {5 e.preventDefault();6 7 const targetId = this.getAttribute('href');8 if (targetId === '#') return;9 10 const targetElement = document.querySelector(targetId);11 if (targetElement) {12 window.scrollTo({13 top: targetElement.offsetTop - 80,14 behavior: 'smooth'15 });16 }17 });18});19 20// Animate elements when they come into view21const animateOnScroll = () => {22 const elements = document.querySelectorAll('.fade-in, .slide-up');23 24 elements.forEach(element => {25 const elementPosition = element.getBoundingClientRect().top;26 const windowHeight = window.innerHeight;27 28 if (elementPosition < windowHeight - 100) {29 element.classList.add('animated');30 }31 });32};33 34// Initialize animations on load35window.addEventListener('load', () => {36 animateOnScroll();37 38 // Add animated class to elements already in view39 document.querySelectorAll('.fade-in, .slide-up').forEach(el => {40 const rect = el.getBoundingClientRect();41 if (rect.top < window.innerHeight - 100) {42 el.classList.add('animated');43 }44 });45});46 47// Add scroll event listener for animations48window.addEventListener('scroll', animateOnScroll);49 50// Mobile menu toggle functionality will be handled by the navbar component51 