CoolFace
Apppublic

aitorfernandez/financieropro-gradient

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes
script.js49 linesDownload Raw Back to root
1document.addEventListener('DOMContentLoaded', function() {2  // Smooth scroll for anchor links3  document.querySelectorAll('a[href^="#"]').forEach(anchor => {4    anchor.addEventListener('click', function(e) {5      e.preventDefault();6      const target = document.querySelector(this.getAttribute('href'));7      if (target) {8        target.scrollIntoView({9          behavior: 'smooth'10        });11      }12    });13  });14 15  // Lazy loading for images16  const lazyImages = document.querySelectorAll('img[data-src]');17  const imageObserver = new IntersectionObserver((entries, observer) => {18    entries.forEach(entry => {19      if (entry.isIntersecting) {20        const img = entry.target;21        img.src = img.dataset.src;22        img.removeAttribute('data-src');23        observer.unobserve(img);24      }25    });26  });27 28  lazyImages.forEach(img => imageObserver.observe(img));29 30  // Parallax effect for hero section31  const heroSection = document.querySelector('section.relative.h-screen');32  if (heroSection) {33    window.addEventListener('scroll', () => {34      const scrollPosition = window.pageYOffset;35      heroSection.style.backgroundPositionY = scrollPosition * 0.5 + 'px';36    });37  }38 39  // Form submission40  const contactForm = document.querySelector('#contact form');41  if (contactForm) {42    contactForm.addEventListener('submit', function(e) {43      e.preventDefault();44      // Form submission logic here45      alert('Thank you for your inquiry. We will contact you shortly.');46      this.reset();47    });48  }49});