MohanG83/sapiens-elegance-noir
0
1document.addEventListener('DOMContentLoaded', () => {2 // Smooth scrolling for anchor links3 document.querySelectorAll('a[href^="#"]').forEach(anchor => {4 anchor.addEventListener('click', function (e) {5 e.preventDefault();6 document.querySelector(this.getAttribute('href')).scrollIntoView({7 behavior: 'smooth'8 });9 });10 });11 12 // Add animations on scroll13 const animateOnScroll = () => {14 const elements = document.querySelectorAll('.fade-in');15 elements.forEach(element => {16 const elementPosition = element.getBoundingClientRect().top;17 const screenPosition = window.innerHeight / 1.2;18 19 if(elementPosition < screenPosition) {20 element.style.opacity = 1;21 }22 });23 };24 25 window.addEventListener('scroll', animateOnScroll);26 animateOnScroll(); // Run once on load27 28 // Form submission handling29 const contactForm = document.querySelector('form');30 if (contactForm) {31 contactForm.addEventListener('submit', (e) => {32 e.preventDefault();33 alert('Thank you for your message! We will get back to you soon.');34 contactForm.reset();35 });36 }37});