diff options
| author | salmonik <raisersoft@proton.me> | 2026-02-07 00:45:28 +0100 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-02-07 00:45:28 +0100 |
| commit | 4ab571290f64527bc321df8f1267376ad9b9043d (patch) | |
| tree | 523538f46d4b435c4e3d69a76724183467ced7ba /js/gradient.js | |
| parent | smooth scrolling when going to divs (diff) | |
| download | site-4ab571290f64527bc321df8f1267376ad9b9043d.tar.gz site-4ab571290f64527bc321df8f1267376ad9b9043d.zip | |
demake the site, and remove external components
Diffstat (limited to 'js/gradient.js')
| -rw-r--r-- | js/gradient.js | 53 |
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 @@ | |||
| 1 | document.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 | }); | ||
