-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
45 lines (39 loc) · 1.56 KB
/
script.js
File metadata and controls
45 lines (39 loc) · 1.56 KB
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
// Form submission handling
const contactForm = document.getElementById('contactForm');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
console.log('Form submitted');
});
}
// Smooth scroll for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
document.addEventListener('DOMContentLoaded', function () {
const cardsContainer = document.querySelector('.testimonial-cards');
const prevBtn = document.getElementById('prevBtn');
const nextBtn = document.getElementById('nextBtn');
let scrollAmount = 320; // Card width including margin
// Scroll Left & Right Buttons
nextBtn.addEventListener('click', () => {
cardsContainer.scrollBy({ left: scrollAmount, behavior: 'smooth' });
});
prevBtn.addEventListener('click', () => {
cardsContainer.scrollBy({ left: -scrollAmount, behavior: 'smooth' });
});
// Auto Scroll Feature
function autoScroll() {
if (cardsContainer.scrollLeft + cardsContainer.clientWidth >= cardsContainer.scrollWidth) {
cardsContainer.scrollTo({ left: 0, behavior: 'smooth' }); // Reset to start
} else {
cardsContainer.scrollBy({ left: scrollAmount, behavior: 'smooth' });
}
}
setInterval(autoScroll, 30000); // Move automatically every 3 seconds
});