-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2bd2471
commit 7d35572
Showing
15 changed files
with
44 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,11 @@ | ||
"use client"; | ||
|
||
import "styles/cards.css"; | ||
import { useEffect, useRef } from "react"; | ||
import Tilt from "react-parallax-tilt"; | ||
|
||
export function GlowEffect({ children, className }) { | ||
const cardContainerRef = useRef(null); | ||
|
||
useEffect(() => { | ||
const cardContainerElement = cardContainerRef.current; | ||
let currentCardElement = null; | ||
|
||
function handleMousemove(e) { | ||
const glowSetting = localStorage.getItem("glow"); | ||
const cardElement = e.target.closest(".card"); | ||
if (!cardElement) return; | ||
|
||
if (currentCardElement !== cardElement) { | ||
if (currentCardElement) { | ||
currentCardElement.style.transition = ""; | ||
currentCardElement.style.transform = ""; | ||
} | ||
currentCardElement = cardElement; | ||
} | ||
|
||
if (glowSetting === "false") { | ||
currentCardElement.style.setProperty("--mouse-x", null); | ||
currentCardElement.style.setProperty("--mouse-y", null); | ||
return; | ||
} | ||
|
||
function getTiltX(dy, height) { | ||
const halfHeight = height / 2; | ||
const normalizedDy = Math.min(Math.max(dy, -halfHeight), halfHeight); | ||
return (-normalizedDy / halfHeight) * 2; | ||
} | ||
|
||
function getTiltY(dx, width) { | ||
const halfWidth = width / 2; | ||
const normalizedDx = Math.min(Math.max(dx, -halfWidth), halfWidth); | ||
return (normalizedDx / halfWidth) * -2; | ||
} | ||
|
||
const rect = cardElement.getBoundingClientRect(); | ||
const cardCenterX = rect.left + rect.width / 2; | ||
const cardCenterY = rect.top + rect.height / 2; | ||
const dx = e.clientX - cardCenterX; | ||
const dy = e.clientY - cardCenterY; | ||
|
||
const tiltX = getTiltX(dy, rect.height); | ||
const tiltY = getTiltY(dx, rect.width); | ||
|
||
currentCardElement.style.setProperty("--mouse-x", `${e.clientX - rect.left}px`); | ||
currentCardElement.style.setProperty("--mouse-y", `${e.clientY - rect.top}px`); | ||
currentCardElement.style.transform = `perspective(700px) rotateX(${tiltX}deg) rotateY(${tiltY}deg)`; | ||
} | ||
|
||
function handleMouseleave() { | ||
if (currentCardElement) { | ||
currentCardElement.style.transform = ""; | ||
currentCardElement = null; | ||
} | ||
} | ||
|
||
if (typeof window !== "undefined" && cardContainerRef.current) { | ||
cardContainerElement.addEventListener("mousemove", handleMousemove); | ||
cardContainerElement.addEventListener("mouseleave", handleMouseleave); | ||
} | ||
|
||
return () => { | ||
cardContainerElement.removeEventListener("mousemove", handleMousemove); | ||
cardContainerElement.removeEventListener("mouseleave", handleMouseleave); | ||
}; | ||
}, [cardContainerRef]); | ||
|
||
return ( | ||
<div ref={cardContainerRef} className={`${className} card-container`}> | ||
<Tilt glareEnable={true} glareMaxOpacity={0.1} glareColor="#ffffff" glarePosition="all" glareBorderRadius="8px" tiltMaxAngleX={5} tiltMaxAngleY={5} className={className}> | ||
{children} | ||
</div> | ||
</Tilt> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,7 +166,7 @@ export const footer = { | |
}, | ||
{ | ||
title: "Contact", | ||
href: "/#contact", | ||
href: "/contact", | ||
}, | ||
], | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.