-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
64 lines (49 loc) · 1.5 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
// MENU BUTTON
document.getElementById('menu-btn').addEventListener('click', function() {
document.querySelector('.mainmenu')?.classList.add('open');
});
document.getElementById('menu-btn2').addEventListener('click', function() {
document.querySelector('.mainmenu')?.classList.remove('open');
});
// SCROLL REVEAL
document.addEventListener("DOMContentLoaded", () => {
const agendaItems = document.querySelectorAll(".agenda-item");
const observerOptions = {
root: null,
threshold: 0.3,
};
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add("reveal");
observer.unobserve(entry.target); // Stop observing once it's revealed
}
});
}, observerOptions);
agendaItems.forEach(item => {
observer.observe(item);
});
});
// H1 ANIMATION
const text = document.querySelector('h1');
const strText = text.textContent;
const splitText = strText.split("");
text.textContent = "";
for (let i = 0; i < splitText.length; i++) {
text.innerHTML += "<span>" + splitText[i] + "</span>";
}
let char = 0;
let timer = setInterval(onTick, 100);
function onTick() {
const span = text.querySelectorAll('span')[char];
span.classList.add('fade');
char++;
if (char === splitText.length) {
complete();
return;
}
}
function complete() {
clearInterval(timer);
timer = null;
}