| |
| document.addEventListener('DOMContentLoaded', function() { |
| |
| 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' |
| }); |
| } |
| }); |
| }); |
|
|
| |
| 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; |
| } |
| }; |
|
|
| |
| const observer = new IntersectionObserver((entries) => { |
| entries.forEach(entry => { |
| if (entry.isIntersecting) { |
| animateCounter(entry.target); |
| } |
| }); |
|
|
| counters.forEach(counter => { |
| observer.observe(counter); |
| }); |
|
|
| |
| 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)`; |
| }); |
|
|
| |
| window.toggleMobileMenu = function() { |
| const mobileMenu = document.getElementById('mobileMenu'); |
| mobileMenu.classList.toggle('hidden'); |
| }; |
|
|
| |
| 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)'; |
| }); |
| }); |
|
|
| |
| const contactForms = document.querySelectorAll('.contact-form'); |
| contactForms.forEach(form => { |
| form.addEventListener('submit', function(e) { |
| e.preventDefault(); |
| |
| alert('Thank you for your message! We will get back to you soon.'); |
| form.reset(); |
| }); |
| }); |
|
|
| |
| 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); |
| }); |
|
|
| |
| window.addEventListener('load', function() { |
| document.body.classList.add('loaded'); |
| }); |
| }); |