summaryrefslogtreecommitdiffstats
path: root/js/gradient.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/gradient.js')
-rw-r--r--js/gradient.js53
1 files changed, 0 insertions, 53 deletions
diff --git a/js/gradient.js b/js/gradient.js
deleted file mode 100644
index 28178f7..0000000
--- a/js/gradient.js
+++ /dev/null
@@ -1,53 +0,0 @@
1document.addEventListener('DOMContentLoaded', () => {
2 // Get the body element to update the cursor position
3 const body = document.documentElement;
4 let mouseX = 0;
5 let mouseY = 0;
6 let smoothX = 0;
7 let smoothY = 0;
8
9 // Smoothing factor (lower = smoother, higher = snappier)
10 const smoothing = 0.1;
11
12 // Handle mouse movement
13 const handleMouseMove = (e) => {
14 mouseY = e.clientY
15 mouseX = e.clientX
16
17 };
18
19 // Smooth the cursor movement
20 const updateCursorLight = () => {
21 // Apply smoothing
22 smoothX += (mouseX - smoothX) * smoothing;
23 smoothY += (mouseY - smoothY) * smoothing;
24
25 // Update CSS variables for the cursor position
26 body.style.setProperty('--cursor-x', `${smoothX}px`);
27 body.style.setProperty('--cursor-y', `${smoothY}px`);
28
29 // Continue the animation loop
30 requestAnimationFrame(updateCursorLight);
31 };
32
33 // Add event listeners
34 window.addEventListener('mousemove', handleMouseMove);
35
36 // Handle touch events for mobile
37 window.addEventListener('touchmove', (e) => {
38 const touch = e.touches[0];
39 handleMouseMove({
40 clientX: touch.clientX,
41 clientY: touch.clientY
42 });
43 }, { passive: false });
44
45 // Initialize cursor position to center of screen
46 mouseX = window.innerWidth / 2;
47 mouseY = window.innerHeight / 2;
48 smoothX = mouseX;
49 smoothY = mouseY;
50
51 // Start the animation loop
52 updateCursorLight();
53});