-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
31 lines (26 loc) · 879 Bytes
/
script.js
File metadata and controls
31 lines (26 loc) · 879 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
28
29
30
31
document.addEventListener('DOMContentLoaded', function() {
const cursorGlow = document.querySelector('.cursor-glow');
let isMoving = false;
let currentX = 0;
let currentY = 0;
let targetX = 0;
let targetY = 0;
document.addEventListener('mousemove', (e) => {
targetX = e.clientX;
targetY = e.clientY;
isMoving = true;
});
function animate() {
if (isMoving) {
currentX += (targetX - currentX) * 0.1;
currentY += (targetY - currentY) * 0.1;
cursorGlow.style.left = `${currentX}px`;
cursorGlow.style.top = `${currentY}px`;
if (Math.abs(targetX - currentX) < 0.1 && Math.abs(targetY - currentY) < 0.1) {
isMoving = false;
}
}
requestAnimationFrame(animate);
}
animate();
});