From ec7280e2667feadc2cb836837b58674279343c34 Mon Sep 17 00:00:00 2001 From: killerboss Date: Sat, 26 Oct 2024 21:36:28 +0200 Subject: [PATCH] Added custom cursor --- cursor.jsx | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 cursor.jsx diff --git a/cursor.jsx b/cursor.jsx new file mode 100644 index 0000000..409f6bf --- /dev/null +++ b/cursor.jsx @@ -0,0 +1,37 @@ +"use client"; +import { useEffect, useRef } from 'react'; +import { gsap } from 'gsap'; + +const CustomCursor = ({ isHoveringButton }) => { + const cursorRef = useRef(null); + + useEffect(() => { + const moveCursor = (e) => { + const { clientX: x, clientY: y } = e; + + gsap.to(cursorRef.current, { + x: x - 16, + y: y - 16, + duration: 0.1, + ease: "power3.out", + }); + }; + + window.addEventListener('mousemove', moveCursor); + + return () => { + window.removeEventListener('mousemove', moveCursor); + }; + }, []); + + return ( + <> +
+ + ); +}; + +export default CustomCursor;