-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
92 lines (71 loc) · 2.61 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
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
85
86
87
88
89
90
91
92
// Appu
function updateTime() {
const timeElement = document.getElementById("time");
const now = new Date();
const hours = String(now.getHours()).padStart(2, "0");
const minutes = String(now.getMinutes()).padStart(2, "0");
const seconds = String(now.getSeconds()).padStart(2, "0");
timeElement.textContent = `${hours}:${minutes}:${seconds}`;
}
updateTime();
setInterval(updateTime, 1000);
// Atul's script.js
let scrollPosition = 0;
let intervalId;
function updateOpacity() {
const container = document.querySelector(".feedback-container");
const items = container.querySelectorAll(".feedback-item");
}
function autoScroll() {
const container = document.querySelector(".feedback-container");
const itemWidth = container.querySelector(".feedback-item").clientWidth;
const maxScroll = container.scrollWidth - container.clientWidth;
scrollPosition = (scrollPosition + itemWidth) % (maxScroll + itemWidth);
container.style.transform = `translateX(-${scrollPosition}px)`;
updateOpacity();
}
function startAutoScroll() {
intervalId = setInterval(autoScroll, 3000); // Scrolls every 3 seconds
}
function stopAutoScroll() {
clearInterval(intervalId);
}
document.addEventListener("DOMContentLoaded", () => {
updateOpacity();
startAutoScroll();
const items = document.querySelectorAll(".feedback-item img");
items.forEach((item) => {
item.addEventListener("mouseenter", () => {
stopAutoScroll();
item.parentElement.style.transform = "scale(1.3)";
item.parentElement.style.zIndex = "10";
});
item.addEventListener("mouseleave", () => {
startAutoScroll();
item.parentElement.style.transform = "scale(1)";
item.parentElement.style.zIndex = "1";
});
});
});
// ----------------------section 6 -------------------------------------------------------
document.addEventListener("DOMContentLoaded", function () {
const faqQuestions = document.querySelectorAll(".faq-question");
faqQuestions.forEach((question) => {
question.addEventListener("click", function () {
const answer = this.nextElementSibling;
const icon = this.querySelector(".toggle-icon");
faqQuestions.forEach((q) => {
if (q !== question) {
q.classList.remove("active");
q.nextElementSibling.classList.remove("active");
q.querySelector(".toggle-icon").textContent = "+";
}
});
question.classList.toggle("active");
answer.classList.toggle("active");
icon.textContent = icon.textContent === "+" ? "x" : "+";
icon.style.transform = "rotate(360deg)";
faqItem.classList.toggle("active");
});
});
});