-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
38 lines (33 loc) · 1.17 KB
/
script.js
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
// Loader
window.addEventListener("load", function () {
const loader = document.getElementById("loader");
loader.classList.add("hidden");
});
// Smooth Scrolling
document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
anchor.addEventListener("click", function (e) {
e.preventDefault();
document.querySelector(this.getAttribute("href")).scrollIntoView({
behavior: "smooth",
});
});
});
// Toggle Theme
const toggleThemeButton = document.getElementById("toggle-theme");
toggleThemeButton.addEventListener("click", () => {
document.body.classList.toggle("dark-theme");
});
// Testimonial Carousel (Manual)
let currentIndex = 0;
const testimonials = document.querySelectorAll(".testimonial");
function showTestimonial(index) {
testimonials.forEach((testimonial, i) => {
testimonial.style.display = i === index ? "block" : "none";
});
}
setInterval(() => {
currentIndex = (currentIndex + 1) % testimonials.length;
showTestimonial(currentIndex);
}, 3000); // Change every 3 seconds
// Initialize the first testimonial
showTestimonial(currentIndex);