diff --git a/src/app/components/SmoothCursor.tsx b/src/app/components/SmoothCursor.tsx new file mode 100644 index 0000000..5ea46b1 --- /dev/null +++ b/src/app/components/SmoothCursor.tsx @@ -0,0 +1,89 @@ +'use client'; + +import { useEffect } from 'react'; + +export default function SmoothCursor() { + useEffect(() => { + const cursor = document.getElementById('magicMouseCursor'); + const pointer = document.getElementById('magicPointer'); + + // variables + let pointerX = 0; + let pointerY = 0; + let targetX = 0; + let targetY = 0; + + // update the position of the cursor and pointer + const onMouseMove = (e: MouseEvent) => { + // update the small cursor to the mouse position + if (cursor) { + cursor.style.left = `${e.clientX}px`; + cursor.style.top = `${e.clientY}px`; + } + // target position for the larger circle + targetX = e.clientX; + targetY = e.clientY; + }; + + // smooth effect i think + const followPointer = () => { + pointerX += (targetX - pointerX) * 0.1; // Adjust the 0.1 for faster/slower following + pointerY += (targetY - pointerY) * 0.1; + if (pointer) { + pointer.style.left = `${pointerX - 20}px`; // Center the pointer + pointer.style.top = `${pointerY - 20}px`; // Center the pointer + } + requestAnimationFrame(followPointer); + }; + + // event listener for mouse move + document.addEventListener('mousemove', onMouseMove); + + + followPointer(); + + // cleanup function + return () => { + document.removeEventListener('mousemove', onMouseMove); + }; + }, []); + + return ( + <> + {/* Small white dot */} +
+ + {/* Larger outline circle */} + + > + ); +} diff --git a/src/app/globals.css b/src/app/globals.css index 3724d61..e974bfb 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -87,3 +87,7 @@ nav ul { .scrollable-gallery::-webkit-scrollbar-thumb:hover { background: #5ec28d; } + +* { + cursor: none; /* we dont want the pesky old cursor anywhere */ +} \ No newline at end of file diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 8fe4518..cee164b 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -2,11 +2,13 @@ import type { Metadata } from 'next'; import './globals.css'; import Navbar from '@/app/components/Navbar'; import BottomBar from '@/app/components/BottomBar'; +import SmoothCursor from '@/app/components/SmoothCursor'; // Import SmoothCursor import type { Viewport } from 'next'; export const viewport: Viewport = { themeColor: '#ff9b05', }; + export const metadata: Metadata = { title: 'BenMerch', description: 'Created by the Mr. Ben Merch Store Club', @@ -27,6 +29,10 @@ export default function RootLayout({ children }: { children: React.ReactNode })