37 lines
949 B
JavaScript
37 lines
949 B
JavaScript
"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 (
|
|
<>
|
|
<div
|
|
ref={cursorRef}
|
|
className={`pointer-events-none fixed top-0 left-0 ${isHoveringButton ? 'invisible' : ''} w-10 h-10 bg-white rounded-full z-50 mix-blend-difference`}
|
|
/>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default CustomCursor;
|