From 607dd617f6fb344e2db1f83456becc1faff9247c Mon Sep 17 00:00:00 2001 From: imnyang Date: Fri, 7 Mar 2025 18:07:37 +0900 Subject: [PATCH] Picture Replaced --- src/App.tsx | 50 ++++++++------------------ src/components/Home/Top.tsx | 72 +++++++++++++++++++++---------------- src/index.css | 19 ---------- 3 files changed, 57 insertions(+), 84 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 44433a2..6f8074e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,63 +1,43 @@ -import { useEffect } from 'react'; +import { useEffect } from "react"; import Top from "@/components/Home/Top"; import About from "@/components/Home/About"; import Timeline from "@/components/Home/Timeline"; -import Contact from '@/components/Home/Contact'; -import Project from '@/components/Home/Project'; +import Contact from "@/components/Home/Contact"; +import Project from "@/components/Home/Project"; -import './index.css'; +import "./index.css"; export function App() { useEffect(() => { - // 초기 로드 시 hash에 맞게 스크롤 - const scrollToHash = () => { - const hash = window.location.hash.substring(1); - if (hash) { - const element = document.getElementById(hash); - if (element) { - setTimeout(() => { - element.scrollIntoView({ behavior: "smooth" }); - }, 100); // 브라우저가 레이아웃을 그릴 시간을 줌 - } + // img 위에서 스크롤 방지 + const handleWheel = (event) => { + if (event.target.tagName.toLowerCase() === "img") { + event.preventDefault(); } }; - scrollToHash(); - // 스크롤 시 hash 업데이트 로직 - const sections = document.querySelectorAll(".section"); - const observer = new IntersectionObserver( - (entries) => { - entries.forEach(entry => { - if (entry.isIntersecting) { - window.history.replaceState(null, "", `#${entry.target.id}`); - } - }); - }, - { threshold: 0.6 } // 60% 보이면 활성화 - ); - - sections.forEach(section => observer.observe(section)); + document.addEventListener("wheel", handleWheel, { passive: false }); return () => { - sections.forEach(section => observer.unobserve(section)); + document.removeEventListener("wheel", handleWheel); }; }, []); return (
-
+
-
+
-
+
-
+
-
+
diff --git a/src/components/Home/Top.tsx b/src/components/Home/Top.tsx index a902472..c4880bd 100644 --- a/src/components/Home/Top.tsx +++ b/src/components/Home/Top.tsx @@ -1,13 +1,30 @@ -import { - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, - } from "@/components/ui/tooltip"; +import { useState } from "react"; import "../../index.css"; -import Image from "../../profile.avif"; - + export default function Top() { + const [mousePos, setMousePos] = useState({ x: 50, y: 50 }); + const [scale, setScale] = useState(1.15); + const [isHovering, setIsHovering] = useState(false); + + const handleMouseMove = (e) => { + const { left, top, width, height } = e.currentTarget.getBoundingClientRect(); + const x = ((e.clientX - left) / width) * 100; + const y = ((e.clientY - top) / height) * 100; + + setMousePos((prev) => ({ + x: prev.x + (x - prev.x) * 0.1, + y: prev.y + (y - prev.y) * 0.1, + })); + }; + + const handleWheel = (e) => { + e.preventDefault(); + setScale((prev) => { + const newScale = prev + e.deltaY * -0.0025; + return Math.min(Math.max(newScale, 1), 3); + }); + }; + return (
@@ -24,28 +41,23 @@ export default function Top() {

- - - -
-
- -
-
-
- - Special Thanks to @dob2_ - -
-
+
setIsHovering(true)} + onMouseLeave={() => setIsHovering(false)} + onWheel={handleWheel} + > + Me +
); diff --git a/src/index.css b/src/index.css index 4ef4218..add9c7e 100644 --- a/src/index.css +++ b/src/index.css @@ -13,22 +13,3 @@ justify-content: center; align-items: center; } - -.avatar-background { - background: none; -} - -@media (min-width: 768px) { - .avatar-background { - position: relative; - overflow: hidden; - background-image: url("https://f.imnya.ng/profile/banner.CjixG8N2_15mivN.webp"); - background-size: cover; - background-position: 400px center; - background-repeat: no-repeat; - background-attachment: fixed; - } - .avatar-background-blur { - backdrop-filter: blur(5px); - } -} \ No newline at end of file