-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
45 lines (37 loc) · 1.25 KB
/
main.js
File metadata and controls
45 lines (37 loc) · 1.25 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
console.clear();
const cursor = document.querySelector(".cursor");
const mask = document.querySelector(".mask");
const list = document.querySelector(".list");
const audio = document.getElementById("soundEffect");
const createElement = (element) => {
document.createElement(element);
};
document.addEventListener("mousemove", (e) => {
// everytime the mouse move we want to adjust style
// 25 is used to center the cursor in the middle of the div
cursor.setAttribute(
"style",
"top: " + (e.pageY - 25) + "px; left: " + (e.pageX - 25) + "px;"
);
//pageY and pageX are (x,y) coordinate properties of the window
// we are concatenting the value of x and y and inserting it into the position absolute positiong propertes left and top
});
document.addEventListener("click", (e) => {
// console.log('clicked');
audio.currentTime = 0;
audio.play();
});
document.addEventListener("click", () => {
cursor.classList.add("expand");
setTimeout( () => {
cursor.classList.remove("expand");
}, 100);
});
mask.style.clipPath = "circle(5px at 50% 50%)";
addEventListener("mousemove", (e) => {
let timeout = 0;
clearTimeout(timeout);
timeout = setTimeout(() => {
mask.style.clipPath = `circle( 45px at ${e.clientX}px ${e.clientY}px )`;
});
});