-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
54 lines (44 loc) · 1.14 KB
/
script.js
File metadata and controls
54 lines (44 loc) · 1.14 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
// initializie and setup the AoS library
AOS.init({
delay: 200,
duration: 1000,
once: false,
});
// this is the fading h1
const h1 = document.querySelector(".hero span");
const h1Text = h1.textContent;
const h1Split = h1Text.split("");
h1.textContent = "";
for (let i = 0; i < h1Split.length; i++) {
h1.innerHTML += "<span>" + h1Split[i] + "</span>";
}
let char = 0;
let timer = setInterval(onTick, 80);
function onTick() {
const span = h1.querySelectorAll("span")[char];
span.classList.add("fade");
char++;
if (char === h1Split.length) {
complete();
return;
}
}
function complete() {
clearInterval(timer);
timer = null;
}
// hamburger menu
const menuButton = document.querySelector(".menu");
const navigation = document.querySelector(".mobile-nav");
const navigationItems = document.querySelectorAll(".mobile-nav li");
menuButton.addEventListener("click", (e) => {
e.preventDefault();
menuButton.style.display = "none";
navigation.style.display = "block";
});
navigationItems.forEach((li) => {
li.addEventListener("click", (e) => {
navigation.style.display = "none";
menuButton.style.display = "block";
});
});