-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
79 lines (68 loc) · 2.71 KB
/
script.js
File metadata and controls
79 lines (68 loc) · 2.71 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
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
document.addEventListener("DOMContentLoaded", function() {
// ============ SCROLL-REVEAL (IntersectionObserver) ============
const revealElements = document.querySelectorAll(".reveal");
const revealObserver = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("visible");
revealObserver.unobserve(entry.target);
}
});
},
{
threshold: 0.12,
rootMargin: "0px 0px -30px 0px",
}
);
revealElements.forEach((el) => revealObserver.observe(el));
// ============ HEADER: Glass shadow on scroll ============
const header = document.querySelector(".clean-header");
if (header) {
window.addEventListener("scroll", () => {
if (window.pageYOffset > 20) {
header.classList.add("scrolled");
} else {
header.classList.remove("scrolled");
}
}, { passive: true });
}
// ============ FAQ ACCORDION ============
const faqQuestions = document.querySelectorAll(".faq-question");
faqQuestions.forEach(question => {
question.addEventListener("click", function() {
// Fecha as outras respostas antes de abrir a clicada
const openQuestions = document.querySelectorAll(".faq-question.active");
openQuestions.forEach(openQ => {
if (openQ !== question) {
openQ.classList.remove("active");
openQ.nextElementSibling.style.maxHeight = null;
}
});
// Adiciona/remove classe active para girar o ícone
this.classList.toggle("active");
// Pegando o painel correspondente (a resposta)
const answer = this.nextElementSibling;
if (answer.style.maxHeight) {
// Se está aberto, fecha
answer.style.maxHeight = null;
} else {
// Se está fechado, abre com base no scrollHeight real
answer.style.maxHeight = answer.scrollHeight + "px";
}
});
});
// ============ CTA BUTTON MICRO-INTERACTION ============
const ctaButtons = document.querySelectorAll(".btn-primary-giant");
ctaButtons.forEach(btn => {
btn.addEventListener("mousedown", function() {
this.style.transform = "translateY(0) scale(0.97)";
});
btn.addEventListener("mouseup", function() {
this.style.transform = "";
});
btn.addEventListener("mouseleave", function() {
this.style.transform = "";
});
});
});