Spaces:
Running
Running
File size: 2,624 Bytes
4f91b68 |
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 78 79 80 81 82 83 84 |
document.addEventListener('DOMContentLoaded', function() {
// Testimonial Slider
const slider = document.querySelector('.testimonial-slider .flex');
const slides = document.querySelectorAll('.testimonial-slide');
const dots = document.querySelectorAll('.testimonial-dot');
const prevBtn = document.querySelector('.testimonial-prev');
const nextBtn = document.querySelector('.testimonial-next');
let currentIndex = 0;
function updateSlider() {
slider.style.transform = `translateX(-${currentIndex * 100}%)`;
// Update dots
dots.forEach((dot, index) => {
if(index === currentIndex) {
dot.classList.add('active');
dot.classList.remove('bg-white/50');
} else {
dot.classList.remove('active');
dot.classList.add('bg-white/50');
}
});
}
// Next slide
function nextSlide() {
currentIndex = (currentIndex + 1) % slides.length;
updateSlider();
}
// Previous slide
function prevSlide() {
currentIndex = (currentIndex - 1 + slides.length) % slides.length;
updateSlider();
}
// Dot navigation
dots.forEach((dot, index) => {
dot.addEventListener('click', () => {
currentIndex = index;
updateSlider();
});
});
// Button events
nextBtn.addEventListener('click', nextSlide);
prevBtn.addEventListener('click', prevSlide);
// Auto slide
let slideInterval = setInterval(nextSlide, 5000);
// Pause on hover
slider.addEventListener('mouseenter', () => {
clearInterval(slideInterval);
});
slider.addEventListener('mouseleave', () => {
slideInterval = setInterval(nextSlide, 5000);
});
// Initialize first dot
dots[0].classList.add('active');
dots[0].classList.remove('bg-white/50');
// Smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
if(targetId === '#') return;
const targetElement = document.querySelector(targetId);
if(targetElement) {
window.scrollTo({
top: targetElement.offsetTop - 80,
behavior: 'smooth'
});
}
});
});
// Mobile menu toggle (handled in navbar component)
}); |