-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathscript.js
39 lines (33 loc) · 1.22 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
const blob = document.getElementById("blob");
const sideMenu = document.getElementById("sidemenu");
const settings_button = document.getElementById("settings-button");
const blur = document.getElementById("blur");
// const hexagon = document.getElementsByClassName("hexagon");
window.addEventListener("pointermove", ({ clientX, clientY }) => {
if (!blob_switch.checked) return;
blob.animate(
{
left: `${clientX}px`,
top: `${clientY}px`,
},
{ duration: 3000, fill: "forwards" }
);
});
settings_button.addEventListener("click", () => sideMenu.classList.add("active"));
blur.addEventListener("click", () => sideMenu.classList.remove("active"));
blob_switch.addEventListener("click", () => {
blob.style.display = blob_switch.checked ? "block" : "none";
localStorage.setItem("blob", blob_switch.checked);
});
rotation_switch.addEventListener("click", () => {
if (rotation_switch.checked) {
for (let i = 0; i < hexagon.length; i++) {
hexagon[i].classList.remove("no-rotation");
};
} else {
for (let i = 0; i < hexagon.length; i++) {
hexagon[i].classList.add("no-rotation");
};
}
localStorage.setItem("rotation", rotation_switch.checked);
});