forked from aditya-bhaumik/Pathsphere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
83 lines (77 loc) · 2.25 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
gsap.from("nav", {
duration: 1,
y: -100,
opacity: 0,
ease: "bounce"
});
gsap.from("h1", {
duration: 1.5,
opacity: 0,
x: -200,
ease: "power3.out",
delay: 0.5
});
gsap.from("p", {
duration: 1.5,
opacity: 0,
x: 200,
ease: "power3.out",
delay: 1
});
gsap.from(".btn", {
duration: 1,
opacity: 0,
scale: 0.5,
stagger: 0.2,
ease: "back.out(1.7)",
delay: 1.5
});
let icon = document.getElementById("icon");
window.onload = function() {
let theme = localStorage.getItem("theme");
if (theme === "dark") {
document.body.classList.add("darkmode");
icon.src = "images/light.png";
} else {
document.body.classList.remove("darkmode");
icon.src = "images/dark.png";
}
}
icon.onclick = function() {
document.body.classList.toggle("darkmode");
if (document.body.classList.contains("darkmode")) {
icon.src = "images/light.png";
localStorage.setItem("theme", "dark");
} else {
icon.src = "images/dark.png";
localStorage.setItem("theme", "light");
}
}
// document.querySelectorAll('.faq-question').forEach(question => {
// question.addEventListener('click', () => {
// const answer = question.nextElementSibling;
// const icon = question.querySelector('.toggle-icon');
// if (answer.style.display === 'block') {
// answer.style.display = 'none';
// icon.textContent = '+';
// } else {
// answer.style.display = 'block';
// icon.textContent = '-';
// }
// });
// });
document.querySelectorAll('.faq-question').forEach(question => {
question.addEventListener('click', () => {
const answer = question.nextElementSibling;
const icon = question.querySelector('.toggle-icon');
if (answer.classList.contains('show')) {
answer.classList.remove('show');
icon.textContent = '+';
icon.classList.remove('rotate');
} else {
answer.classList.add('show');
icon.textContent = '-';
icon.classList.add('rotate'); // A
}
});
});