File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import type { Metadata } from "next";
3
3
import { Inter } from "next/font/google" ;
4
4
import { Navbar } from "../components/Navbar" ;
5
5
import GlobalWrapper from "../components/common/GlobalWrapper" ;
6
+ import CursorFollower from "../components/common/CursorFollower" ;
6
7
7
8
const inter = Inter ( { subsets : [ "latin" ] } ) ;
8
9
@@ -19,6 +20,7 @@ export default function RootLayout({
19
20
return (
20
21
< html lang = "en" >
21
22
< body className = { inter . className } >
23
+ < CursorFollower />
22
24
< GlobalWrapper >
23
25
< Navbar />
24
26
{ children }
Original file line number Diff line number Diff line change
1
+ "use client" ;
2
+ import { useEffect , useRef } from "react" ;
3
+
4
+ const CursorFollower = ( ) => {
5
+ const cursorRef = useRef < HTMLDivElement > ( null ) ;
6
+
7
+ useEffect ( ( ) => {
8
+ const moveCursor = ( e : MouseEvent ) => {
9
+ if ( cursorRef . current ) {
10
+ cursorRef . current . style . transform = `translate(${ e . clientX } px, ${ e . clientY } px)` ;
11
+ }
12
+ } ;
13
+
14
+ document . addEventListener ( "mousemove" , moveCursor ) ;
15
+ return ( ) => document . removeEventListener ( "mousemove" , moveCursor ) ;
16
+ } , [ ] ) ;
17
+
18
+ return (
19
+ < div
20
+ ref = { cursorRef }
21
+ className = "fixed z-[50] top-0 left-0 w-6 h-6 bg-white/70 opacity-75 rounded-full pointer-events-none shadow-[0_0_10px_#fff] transition-transform duration-75 ease-out"
22
+ />
23
+ ) ;
24
+ } ;
25
+
26
+ export default CursorFollower ;
You can’t perform that action at this time.
0 commit comments