Spaces:
Running
Running
File size: 2,363 Bytes
5bdc1d9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | // Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Sticky navbar
window.addEventListener('scroll', function() {
const navbar = document.querySelector('custom-navbar');
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Animation on scroll
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate-fadeIn');
}
});
}, observerOptions);
document.querySelectorAll('.feature-card, .testimonial-card').forEach(card => {
observer.observe(card);
});
// Form validation for transport quote
document.addEventListener('DOMContentLoaded', function() {
const quoteForm = document.querySelector('#transport-quote form');
if (quoteForm) {
quoteForm.addEventListener('submit', function(e) {
e.preventDefault();
// Simple validation
let isValid = true;
const inputs = this.querySelectorAll('input');
inputs.forEach(input => {
if (!input.value.trim()) {
isValid = false;
input.classList.add('border-red-500');
} else {
input.classList.remove('border-red-500');
}
});
if (isValid) {
// In a real app, this would submit to a server
alert('Quote calculated! In a real application, this would show your personalized quote.');
}
});
}
});
// Parallax effect for hero section
document.addEventListener('mousemove', (e) => {
const hero = document.querySelector('.parallax');
if (!hero) return;
const xAxis = (window.innerWidth / 2 - e.pageX) / 25;
const yAxis = (window.innerHeight / 2 - e.pageY) / 25;
hero.style.transform = `rotateY(${xAxis}deg) rotateX(${yAxis}deg)`;
}); |