-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
27 lines (23 loc) · 726 Bytes
/
scripts.js
File metadata and controls
27 lines (23 loc) · 726 Bytes
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
const cursorDot = document.querySelector("[ data-cursor-dot]");
const cursorOutline = document.querySelector("[ data-cursor-outline]");
window.addEventListener("mouseover", () => {
cursorDot.style = "display:block";
cursorOutline.style = "display:block";
window.addEventListener("mousemove", (e) => {
const posX = e.clientX;
const posY = e.clientY;
cursorDot.style.left = `${posX}px`;
cursorDot.style.top = `${posY}px`;
cursorOutline.animate(
{
left: `${posX}px`,
top: `${posY}px`,
},
{ duration: 300, fill: "forwards" }
);
});
});
window.addEventListener("mouseout", () => {
cursorDot.style = "display:none";
cursorOutline.style = "display:none";
});