Added custom cursor
This commit is contained in:
parent
43eae73922
commit
ec7280e266
1 changed files with 37 additions and 0 deletions
37
cursor.jsx
Normal file
37
cursor.jsx
Normal file
|
@ -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 (
|
||||
<>
|
||||
<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;
|
Loading…
Reference in a new issue