-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
executable file
·55 lines (41 loc) · 1.17 KB
/
script.js
File metadata and controls
executable file
·55 lines (41 loc) · 1.17 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
/* -- Glow effect -- */
const blob = document.getElementById("blob");
window.onpointermove = (event) => {
const { clientX, clientY } = event;
blob.animate(
{
left: `${clientX}px`,
top: `${clientY}px`,
},
{ duration: 1000, fill: "forwards" }
);
};
/* -- Text effect -- */
const letters = "ABCD2345I4KLMN0PQRSTUVW9YZ";
let interval = null;
document.querySelector("h1").onmouseover = (event) => {
let iteration = 0;
clearInterval(interval);
interval = setInterval(() => {
event.target.innerText = event.target.innerText
.split("")
.map((letter, index) => {
if (index < iteration) {
return event.target.dataset.value[index];
}
return letters[Math.floor(Math.random() * 26)];
})
.join("");
if (iteration >= event.target.dataset.value.length) {
clearInterval(interval);
}
iteration += 1 / 3;
}, 75);
};
const button = document.getElementById("menu-toggle");
const toggle = () => {
document.body.classList.toggle("menu-toggled");
};
// need to fix this!!
button.onclick = () => toggle();
setTimeout(toggle, 200);