From faf548b82a51a28284422819fceaab67a785ea4f Mon Sep 17 00:00:00 2001 From: Cupid Valentine Date: Sun, 20 Oct 2024 23:54:04 +0800 Subject: [PATCH] feat: add cursor style --- components/BackgroundWrapper.tsx | 2 ++ components/Cursor.tsx | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 components/Cursor.tsx diff --git a/components/BackgroundWrapper.tsx b/components/BackgroundWrapper.tsx index 91a729c..0a3bed9 100644 --- a/components/BackgroundWrapper.tsx +++ b/components/BackgroundWrapper.tsx @@ -5,6 +5,7 @@ import { Canvas, useFrame } from '@react-three/fiber' import { motion } from 'framer-motion' import dynamic from 'next/dynamic' import React, { useRef } from 'react' +import Cursor from './Cursor' import { pointsInner, pointsOuter } from './utils' const ScrollTopAndComment = dynamic(() => import('./ScrollTopAndComment'), { ssr: false }) @@ -60,6 +61,7 @@ function Point({ position, color }) { export default function BackgroundWrapper({ children }: { children: React.ReactNode }) { return (
+ { + const mouseMove = (e) => { + setPosition({ x: e.clientX, y: e.clientY }) + } + + window.addEventListener('mousemove', mouseMove) + + return () => { + window.removeEventListener('mousemove', mouseMove) + } + }, []) + + return ( + + + ) +}