Fade in on bgs & sticky nav
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
.card-nav-container {
|
||||
position: absolute;
|
||||
top: 2em;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
position: sticky;
|
||||
top: 1.5em;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
width: 90%;
|
||||
max-width: 800px;
|
||||
z-index: 99;
|
||||
z-index: 999;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 2em;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.card-nav {
|
||||
@@ -32,7 +34,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.5rem 0.8rem; /* Ajusté pour laisser de la place */
|
||||
padding: 0.5rem 0.8rem;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
.card-swap-container {
|
||||
position: relative;
|
||||
margin: 0 auto;
|
||||
perspective: 1500px;
|
||||
overflow: visible;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.card {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform-style: preserve-3d;
|
||||
will-change: transform;
|
||||
pointer-events: auto !important;
|
||||
}
|
||||
|
||||
/* Responsive : On réduit la taille des cartes de 800px sur mobile */
|
||||
@media (max-width: 1024px) {
|
||||
.card-swap-container {
|
||||
transform: scale(0.8);
|
||||
}
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
.card-swap-container {
|
||||
transform: scale(0.5);
|
||||
}
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
import React, {
|
||||
Children,
|
||||
cloneElement,
|
||||
forwardRef,
|
||||
isValidElement,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
} from "react";
|
||||
import gsap from "gsap";
|
||||
import "./CardSwap.css";
|
||||
|
||||
export const Card = forwardRef(({ customClass, ...rest }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
{...rest}
|
||||
className={`card ${customClass ?? ""} ${rest.className ?? ""}`.trim()}
|
||||
/>
|
||||
));
|
||||
Card.displayName = "Card";
|
||||
|
||||
const makeSlot = (i, distX, distY, total) => ({
|
||||
x: i * distX,
|
||||
y: -i * distY,
|
||||
z: -i * distX * 1.5,
|
||||
zIndex: total - i,
|
||||
});
|
||||
const placeNow = (el, slot, skew) =>
|
||||
gsap.set(el, {
|
||||
x: slot.x,
|
||||
y: slot.y,
|
||||
z: slot.z,
|
||||
xPercent: -50,
|
||||
yPercent: -50,
|
||||
skewY: skew,
|
||||
transformOrigin: "center center",
|
||||
zIndex: slot.zIndex,
|
||||
force3D: true,
|
||||
});
|
||||
|
||||
const CardSwap = ({
|
||||
width = 500,
|
||||
height = 400,
|
||||
cardDistance = 60,
|
||||
verticalDistance = 70,
|
||||
delay = 5000,
|
||||
pauseOnHover = false,
|
||||
onCardClick,
|
||||
skewAmount = 6,
|
||||
easing = "elastic",
|
||||
children,
|
||||
}) => {
|
||||
const config =
|
||||
easing === "elastic"
|
||||
? {
|
||||
ease: "elastic.out(0.6,0.9)",
|
||||
durDrop: 2,
|
||||
durMove: 2,
|
||||
durReturn: 2,
|
||||
promoteOverlap: 0.9,
|
||||
returnDelay: 0.05,
|
||||
}
|
||||
: {
|
||||
ease: "power1.inOut",
|
||||
durDrop: 0.8,
|
||||
durMove: 0.8,
|
||||
durReturn: 0.8,
|
||||
promoteOverlap: 0.45,
|
||||
returnDelay: 0.2,
|
||||
};
|
||||
|
||||
const childArr = useMemo(() => Children.toArray(children), [children]);
|
||||
const refs = useMemo(
|
||||
() => childArr.map(() => React.createRef()),
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[childArr.length],
|
||||
);
|
||||
|
||||
const order = useRef(Array.from({ length: childArr.length }, (_, i) => i));
|
||||
|
||||
const tlRef = useRef(null);
|
||||
const intervalRef = useRef();
|
||||
const container = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
const total = refs.length;
|
||||
refs.forEach((r, i) =>
|
||||
placeNow(
|
||||
r.current,
|
||||
makeSlot(i, cardDistance, verticalDistance, total),
|
||||
skewAmount,
|
||||
),
|
||||
);
|
||||
|
||||
const swap = () => {
|
||||
if (order.current.length < 2) return;
|
||||
|
||||
const [front, ...rest] = order.current;
|
||||
const elFront = refs[front].current;
|
||||
const tl = gsap.timeline();
|
||||
tlRef.current = tl;
|
||||
|
||||
tl.to(elFront, {
|
||||
y: "+=500",
|
||||
duration: config.durDrop,
|
||||
ease: config.ease,
|
||||
});
|
||||
|
||||
tl.addLabel("promote", `-=${config.durDrop * config.promoteOverlap}`);
|
||||
rest.forEach((idx, i) => {
|
||||
const el = refs[idx].current;
|
||||
const slot = makeSlot(i, cardDistance, verticalDistance, refs.length);
|
||||
tl.set(el, { zIndex: slot.zIndex }, "promote");
|
||||
tl.to(
|
||||
el,
|
||||
{
|
||||
x: slot.x,
|
||||
y: slot.y,
|
||||
z: slot.z,
|
||||
duration: config.durMove,
|
||||
ease: config.ease,
|
||||
},
|
||||
`promote+=${i * 0.15}`,
|
||||
);
|
||||
});
|
||||
|
||||
const backSlot = makeSlot(
|
||||
refs.length - 1,
|
||||
cardDistance,
|
||||
verticalDistance,
|
||||
refs.length,
|
||||
);
|
||||
tl.addLabel("return", `promote+=${config.durMove * config.returnDelay}`);
|
||||
tl.call(
|
||||
() => {
|
||||
gsap.set(elFront, { zIndex: backSlot.zIndex });
|
||||
},
|
||||
undefined,
|
||||
"return",
|
||||
);
|
||||
tl.to(
|
||||
elFront,
|
||||
{
|
||||
x: backSlot.x,
|
||||
y: backSlot.y,
|
||||
z: backSlot.z,
|
||||
duration: config.durReturn,
|
||||
ease: config.ease,
|
||||
},
|
||||
"return",
|
||||
);
|
||||
|
||||
tl.call(() => {
|
||||
order.current = [...rest, front];
|
||||
});
|
||||
};
|
||||
|
||||
swap();
|
||||
intervalRef.current = window.setInterval(swap, delay);
|
||||
|
||||
if (pauseOnHover) {
|
||||
const node = container.current;
|
||||
const pause = () => {
|
||||
tlRef.current?.pause();
|
||||
clearInterval(intervalRef.current);
|
||||
};
|
||||
const resume = () => {
|
||||
tlRef.current?.play();
|
||||
intervalRef.current = window.setInterval(swap, delay);
|
||||
};
|
||||
node.addEventListener("mouseenter", pause);
|
||||
node.addEventListener("mouseleave", resume);
|
||||
return () => {
|
||||
node.removeEventListener("mouseenter", pause);
|
||||
node.removeEventListener("mouseleave", resume);
|
||||
clearInterval(intervalRef.current);
|
||||
};
|
||||
}
|
||||
return () => clearInterval(intervalRef.current);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [cardDistance, verticalDistance, delay, pauseOnHover, skewAmount, easing]);
|
||||
|
||||
const rendered = childArr.map((child, i) =>
|
||||
isValidElement(child)
|
||||
? cloneElement(child, {
|
||||
key: i,
|
||||
ref: refs[i],
|
||||
style: { width, height, ...(child.props.style ?? {}) },
|
||||
onClick: (e) => {
|
||||
child.props.onClick?.(e);
|
||||
onCardClick?.(i);
|
||||
},
|
||||
})
|
||||
: child,
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={container}
|
||||
className="card-swap-container "
|
||||
style={{ width, height }}
|
||||
>
|
||||
{rendered}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CardSwap;
|
||||
@@ -0,0 +1,276 @@
|
||||
import React, {
|
||||
Children,
|
||||
cloneElement,
|
||||
forwardRef,
|
||||
isValidElement,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
ReactElement,
|
||||
HTMLAttributes,
|
||||
} from "react";
|
||||
import gsap from "gsap";
|
||||
|
||||
// --- Types ---
|
||||
interface Slot {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
zIndex: number;
|
||||
}
|
||||
|
||||
interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
||||
customClass?: string;
|
||||
}
|
||||
|
||||
interface CardSwapProps {
|
||||
width?: number | string;
|
||||
height?: number | string;
|
||||
cardDistance?: number;
|
||||
verticalDistance?: number;
|
||||
delay?: number;
|
||||
pauseOnHover?: boolean;
|
||||
onCardClick?: (index: number) => void;
|
||||
skewAmount?: number;
|
||||
easing?: "elastic" | "smooth";
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
// --- Composant Card ---
|
||||
export const Card = forwardRef<HTMLDivElement, CardProps>(
|
||||
({ customClass, className, ...rest }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
{...rest}
|
||||
className={`absolute top-1/2 left-1/2 transform-3d will-change-transform pointer-events-auto! ${customClass ?? ""} ${className ?? ""}`.trim()}
|
||||
/>
|
||||
),
|
||||
);
|
||||
Card.displayName = "Card";
|
||||
|
||||
// --- Helpers de positionnement ---
|
||||
const makeSlot = (
|
||||
i: number,
|
||||
distX: number,
|
||||
distY: number,
|
||||
total: number,
|
||||
): Slot => ({
|
||||
x: i * distX,
|
||||
y: -i * distY,
|
||||
z: -i * distX * 1.5,
|
||||
zIndex: total - i,
|
||||
});
|
||||
|
||||
const placeNow = (el: HTMLDivElement | null, slot: Slot, skew: number) => {
|
||||
if (!el) return;
|
||||
gsap.set(el, {
|
||||
x: slot.x,
|
||||
y: slot.y,
|
||||
z: slot.z,
|
||||
xPercent: -50,
|
||||
yPercent: -50,
|
||||
skewY: skew,
|
||||
transformOrigin: "center center",
|
||||
zIndex: slot.zIndex,
|
||||
force3D: true,
|
||||
});
|
||||
};
|
||||
|
||||
// --- Composant Principal ---
|
||||
const CardSwap: React.FC<CardSwapProps> = ({
|
||||
width = 500,
|
||||
height = 400,
|
||||
cardDistance = 60,
|
||||
verticalDistance = 70,
|
||||
delay = 5000,
|
||||
pauseOnHover = false,
|
||||
onCardClick,
|
||||
skewAmount = 6,
|
||||
easing = "elastic",
|
||||
children,
|
||||
}) => {
|
||||
const config = useMemo(
|
||||
() =>
|
||||
easing === "elastic"
|
||||
? {
|
||||
ease: "elastic.out(0.6,0.9)",
|
||||
durDrop: 2,
|
||||
durMove: 2,
|
||||
durReturn: 2,
|
||||
promoteOverlap: 0.9,
|
||||
returnDelay: 0.05,
|
||||
}
|
||||
: {
|
||||
ease: "power1.inOut",
|
||||
durDrop: 0.8,
|
||||
durMove: 0.8,
|
||||
durReturn: 0.8,
|
||||
promoteOverlap: 0.45,
|
||||
returnDelay: 0.2,
|
||||
},
|
||||
[easing],
|
||||
);
|
||||
|
||||
const childArr = useMemo(() => Children.toArray(children), [children]);
|
||||
|
||||
// Correction Erreur 2322 : Typage explicite des refs
|
||||
const refs = useMemo(
|
||||
() => childArr.map(() => React.createRef<HTMLDivElement>()),
|
||||
[childArr.length],
|
||||
);
|
||||
|
||||
const order = useRef<number[]>(
|
||||
Array.from({ length: childArr.length }, (_, i) => i),
|
||||
);
|
||||
const tlRef = useRef<gsap.core.Timeline | null>(null);
|
||||
const intervalRef = useRef<number | null>(null);
|
||||
const container = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const total = refs.length;
|
||||
if (total === 0) return;
|
||||
|
||||
// Positionnement initial
|
||||
refs.forEach((r, i) => {
|
||||
placeNow(
|
||||
r.current,
|
||||
makeSlot(i, cardDistance, verticalDistance, total),
|
||||
skewAmount,
|
||||
);
|
||||
});
|
||||
|
||||
const swap = () => {
|
||||
if (order.current.length < 2) return;
|
||||
|
||||
const [front, ...rest] = order.current;
|
||||
const elFront = refs[front].current;
|
||||
if (!elFront) return;
|
||||
|
||||
const tl = gsap.timeline();
|
||||
tlRef.current = tl;
|
||||
|
||||
// Animation de descente
|
||||
tl.to(elFront, {
|
||||
y: "+=500",
|
||||
duration: config.durDrop,
|
||||
ease: config.ease,
|
||||
});
|
||||
|
||||
tl.addLabel("promote", `-=${config.durDrop * config.promoteOverlap}`);
|
||||
|
||||
// Avancement des autres cartes
|
||||
rest.forEach((idx, i) => {
|
||||
const el = refs[idx].current;
|
||||
if (!el) return;
|
||||
const slot = makeSlot(i, cardDistance, verticalDistance, total);
|
||||
|
||||
tl.set(el, { zIndex: slot.zIndex }, "promote");
|
||||
tl.to(
|
||||
el,
|
||||
{
|
||||
x: slot.x,
|
||||
y: slot.y,
|
||||
z: slot.z,
|
||||
duration: config.durMove,
|
||||
ease: config.ease,
|
||||
},
|
||||
`promote+=${i * 0.15}`,
|
||||
);
|
||||
});
|
||||
|
||||
// Retour de la carte de devant vers le fond
|
||||
const backSlot = makeSlot(
|
||||
total - 1,
|
||||
cardDistance,
|
||||
verticalDistance,
|
||||
total,
|
||||
);
|
||||
tl.addLabel("return", `promote+=${config.durMove * config.returnDelay}`);
|
||||
|
||||
tl.set(elFront, { zIndex: backSlot.zIndex }, "return");
|
||||
tl.to(
|
||||
elFront,
|
||||
{
|
||||
x: backSlot.x,
|
||||
y: backSlot.y,
|
||||
z: backSlot.z,
|
||||
duration: config.durReturn,
|
||||
ease: config.ease,
|
||||
},
|
||||
"return",
|
||||
);
|
||||
|
||||
tl.call(() => {
|
||||
order.current = [...rest, front];
|
||||
});
|
||||
};
|
||||
|
||||
intervalRef.current = window.setInterval(swap, delay);
|
||||
|
||||
// Gestion du Hover
|
||||
const node = container.current;
|
||||
if (pauseOnHover && node) {
|
||||
const pause = () => {
|
||||
tlRef.current?.pause();
|
||||
if (intervalRef.current) clearInterval(intervalRef.current);
|
||||
};
|
||||
const resume = () => {
|
||||
tlRef.current?.play();
|
||||
intervalRef.current = window.setInterval(swap, delay);
|
||||
};
|
||||
node.addEventListener("mouseenter", pause);
|
||||
node.addEventListener("mouseleave", resume);
|
||||
|
||||
return () => {
|
||||
node.removeEventListener("mouseenter", pause);
|
||||
node.removeEventListener("mouseleave", resume);
|
||||
if (intervalRef.current) clearInterval(intervalRef.current);
|
||||
};
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (intervalRef.current) clearInterval(intervalRef.current);
|
||||
};
|
||||
}, [
|
||||
cardDistance,
|
||||
verticalDistance,
|
||||
delay,
|
||||
pauseOnHover,
|
||||
skewAmount,
|
||||
config,
|
||||
refs,
|
||||
]);
|
||||
|
||||
// Rendu des enfants avec injection des props
|
||||
const rendered = childArr.map((child, i) => {
|
||||
if (!isValidElement(child)) return child;
|
||||
|
||||
const typedChild = child as ReactElement<any>;
|
||||
return cloneElement(typedChild, {
|
||||
key: i,
|
||||
ref: refs[i],
|
||||
style: {
|
||||
width,
|
||||
height,
|
||||
...(typedChild.props.style ?? {}),
|
||||
},
|
||||
onClick: (e: React.MouseEvent) => {
|
||||
typedChild.props.onClick?.(e);
|
||||
onCardClick?.(i);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={container}
|
||||
className="relative mx-auto perspective-[1500px] overflow-visible pointer-events-none lg:scale-100 md:scale-[0.8] scale-[0.5]"
|
||||
style={{ width, height }}
|
||||
>
|
||||
{rendered}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CardSwap;
|
||||
@@ -85,14 +85,12 @@
|
||||
.details-inner {
|
||||
padding: 4rem 4vw;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 2fr;
|
||||
gap: 4rem;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.details-inner {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,24 @@ function FlowingMenu({
|
||||
borderColor = "rgba(255,255,255,0.1)",
|
||||
}) {
|
||||
const [activeIdx, setActiveIdx] = useState(null);
|
||||
const [isTransitioning, setIsTransitioning] = useState(false);
|
||||
|
||||
const toggleItem = (idx) => {
|
||||
setActiveIdx(activeIdx === idx ? null : idx);
|
||||
if (isTransitioning) return;
|
||||
if (activeIdx === idx) {
|
||||
setActiveIdx(null);
|
||||
return;
|
||||
}
|
||||
if (activeIdx !== null) {
|
||||
setIsTransitioning(true);
|
||||
setActiveIdx(null);
|
||||
setTimeout(() => {
|
||||
setActiveIdx(idx);
|
||||
setIsTransitioning(false);
|
||||
}, 500);
|
||||
} else {
|
||||
setActiveIdx(idx);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -36,7 +51,6 @@ function FlowingMenu({
|
||||
borderColor={borderColor}
|
||||
/>
|
||||
))}
|
||||
|
||||
<div
|
||||
style={{
|
||||
height: activeIdx !== null ? "60vh" : "0px",
|
||||
@@ -112,6 +126,8 @@ function MenuItem({
|
||||
useEffect(() => {
|
||||
if (isOpen && itemRef.current) {
|
||||
const isMobile = window.innerWidth < 768;
|
||||
gsap.killTweensOf([contentRef.current, window, marqueeRef.current]);
|
||||
|
||||
gsap.to(contentRef.current, {
|
||||
height: "auto",
|
||||
opacity: 1,
|
||||
@@ -120,7 +136,7 @@ function MenuItem({
|
||||
});
|
||||
gsap.to(window, {
|
||||
duration: isMobile ? 0.8 : 1,
|
||||
delay: 0.35,
|
||||
delay: 0.1,
|
||||
scrollTo: {
|
||||
y: itemRef.current,
|
||||
offsetY: isMobile ? 0 : 60,
|
||||
@@ -134,6 +150,7 @@ function MenuItem({
|
||||
ease: "power2.out",
|
||||
});
|
||||
} else {
|
||||
gsap.killTweensOf(contentRef.current);
|
||||
gsap.to(contentRef.current, {
|
||||
height: 0,
|
||||
opacity: 0,
|
||||
@@ -171,8 +188,6 @@ function MenuItem({
|
||||
>
|
||||
{text}
|
||||
</div>
|
||||
|
||||
{/* ZONE DÉTAILS */}
|
||||
<div
|
||||
className="service-details-wrapper"
|
||||
ref={contentRef}
|
||||
@@ -180,9 +195,6 @@ function MenuItem({
|
||||
>
|
||||
<div className="details-inner">{Component && <Component />}</div>
|
||||
</div>
|
||||
|
||||
{/* MARQUEE */}
|
||||
{/* Note : Le background est géré par le CSS pour le glassmorphism */}
|
||||
<div className="marquee" ref={marqueeRef}>
|
||||
<div className="marquee__inner-wrap">
|
||||
<div
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
:root {
|
||||
--white: #ffffff;
|
||||
--accent-primary: rgba(183, 28, 28, 1);
|
||||
--accent-glow: rgba(183, 28, 28, 0.3);
|
||||
--border-color: #1a0505;
|
||||
--background-dark: #050000;
|
||||
}
|
||||
|
||||
.card-grid {
|
||||
display: grid;
|
||||
gap: 0.75em;
|
||||
padding: 1em;
|
||||
max-width: 60em;
|
||||
margin: 0 auto;
|
||||
font-size: clamp(1rem, 0.9rem + 0.5vw, 1.5rem);
|
||||
}
|
||||
|
||||
.magic-bento-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
aspect-ratio: 4/3;
|
||||
min-height: 220px;
|
||||
width: 100%;
|
||||
padding: 1.5em;
|
||||
border-radius: 20px;
|
||||
border: 1px solid var(--border-color);
|
||||
background-color: var(--background-dark);
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
overflow: hidden;
|
||||
transition:
|
||||
transform 0.3s ease,
|
||||
box-shadow 0.3s ease;
|
||||
z-index: 1;
|
||||
|
||||
--glow-x: 50%;
|
||||
--glow-y: 50%;
|
||||
--glow-intensity: 0;
|
||||
--glow-radius: 500px; /* Augmenté pour couvrir toute la carte */
|
||||
}
|
||||
|
||||
/* OVERLAY IMAGE (Assombrissement) */
|
||||
.magic-bento-card::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
rgba(0, 0, 0, 0.4),
|
||||
rgba(0, 0, 0, 0.8)
|
||||
);
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
/* BORDURE ÉPAISSE & SPOTLIGHT */
|
||||
.magic-bento-card--border-glow::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
|
||||
/* --- ÉPAISSEUR DE LA BORDURE --- */
|
||||
padding: 6px;
|
||||
|
||||
background: radial-gradient(
|
||||
var(--glow-radius) circle at var(--glow-x) var(--glow-y),
|
||||
rgba(183, 28, 28, calc(var(--glow-intensity) * 1)) 0%,
|
||||
rgba(183, 28, 28, calc(var(--glow-intensity) * 0.4)) 50%,
|
||||
transparent 80%
|
||||
);
|
||||
border-radius: inherit;
|
||||
-webkit-mask:
|
||||
linear-gradient(#fff 0 0) content-box,
|
||||
linear-gradient(#fff 0 0);
|
||||
mask:
|
||||
linear-gradient(#fff 0 0) content-box,
|
||||
linear-gradient(#fff 0 0);
|
||||
-webkit-mask-composite: xor;
|
||||
mask-composite: exclude;
|
||||
|
||||
pointer-events: none;
|
||||
opacity: 1;
|
||||
transition: opacity 0.3s ease;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.magic-bento-card:hover {
|
||||
transform: translateY(-5px);
|
||||
/* Lueur externe supplémentaire au survol */
|
||||
box-shadow: 0 0 30px rgba(183, 28, 28, 0.2);
|
||||
}
|
||||
|
||||
.magic-bento-card__header,
|
||||
.magic-bento-card__content {
|
||||
z-index: 4;
|
||||
position: relative;
|
||||
color: var(--white);
|
||||
}
|
||||
|
||||
/* Typographie */
|
||||
.magic-bento-card__label {
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
color: var(--accent-primary);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
|
||||
.magic-bento-card__title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.magic-bento-card__description {
|
||||
font-size: 1rem;
|
||||
opacity: 0.7;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
/* Grille Layout (Modèle original) */
|
||||
@media (min-width: 1024px) {
|
||||
.card-grid {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
.magic-bento-card:nth-child(3) {
|
||||
grid-column: span 2;
|
||||
grid-row: span 2;
|
||||
}
|
||||
.magic-bento-card:nth-child(4) {
|
||||
grid-column: 1 / span 2;
|
||||
grid-row: 2 / span 2;
|
||||
}
|
||||
.magic-bento-card:nth-child(6) {
|
||||
grid-column: 4;
|
||||
grid-row: 3;
|
||||
}
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
import { useRef, useEffect, useCallback } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { gsap } from "gsap";
|
||||
import "./MagicBento.css";
|
||||
|
||||
const DEFAULT_GLOW_COLOR = "183, 28, 28";
|
||||
|
||||
const cardData = [
|
||||
{
|
||||
title: "Metz Campus",
|
||||
image: "/images/MC.png",
|
||||
description: "Web platform for students.",
|
||||
label: "Web site",
|
||||
link: "https://metzcampus.fr",
|
||||
},
|
||||
{
|
||||
title: "Neo Tokyo Rush",
|
||||
image: "/images/NTR.png",
|
||||
description: "Cyberpunk-inspired beat 'em All game.",
|
||||
label: "Gamedev",
|
||||
link: "/projects/neo-tokyo-rush",
|
||||
},
|
||||
{
|
||||
title: "About Co Hai Se",
|
||||
image: "/images/Cohaise.jpg",
|
||||
description: "Crafting the Web of Your Ambitions.",
|
||||
label: "Identity",
|
||||
link: "/cohaise",
|
||||
},
|
||||
{
|
||||
title: "Contact",
|
||||
image: "/images/Contact.jpg",
|
||||
description: "Reach out to me.",
|
||||
label: "Network",
|
||||
link: "/contact",
|
||||
},
|
||||
{
|
||||
title: "Затишок",
|
||||
image: "/images/Zatyshok.png",
|
||||
description: "Moodboard developped with love.",
|
||||
label: "Desktop App",
|
||||
link: "/projects/zatyshok",
|
||||
},
|
||||
{
|
||||
title: "Shadow Purge - Rite of the Demon",
|
||||
image: "/images/SPRotD.png",
|
||||
description: "Hack n'slash RPG.",
|
||||
label: "Gamedev",
|
||||
link: "/projects/shadow-purge-rite-of-the-demon",
|
||||
},
|
||||
];
|
||||
|
||||
const createParticleElement = (x, y, color) => {
|
||||
const el = document.createElement("div");
|
||||
el.className = "particle";
|
||||
el.style.cssText = `position: absolute; width: 3px; height: 3px; border-radius: 50%; background: rgba(${color}, 1); box-shadow: 0 0 6px rgba(${color}, 0.6); pointer-events: none; z-index: 10; left: ${x}px; top: ${y}px;`;
|
||||
return el;
|
||||
};
|
||||
|
||||
const ParticleCard = ({ children, className, glowColor, onClick, style }) => {
|
||||
const cardRef = useRef(null);
|
||||
const particlesRef = useRef([]);
|
||||
const timeoutsRef = useRef([]);
|
||||
|
||||
const clearParticles = useCallback(() => {
|
||||
timeoutsRef.current.forEach(clearTimeout);
|
||||
timeoutsRef.current = [];
|
||||
particlesRef.current.forEach((p) => {
|
||||
gsap.to(p, {
|
||||
scale: 0,
|
||||
opacity: 0,
|
||||
duration: 0.3,
|
||||
onComplete: () => p.parentNode?.removeChild(p),
|
||||
});
|
||||
});
|
||||
particlesRef.current = [];
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const el = cardRef.current;
|
||||
if (!el) return;
|
||||
|
||||
const handleMove = (e) => {
|
||||
const r = el.getBoundingClientRect();
|
||||
el.style.setProperty(
|
||||
"--glow-x",
|
||||
`${((e.clientX - r.left) / r.width) * 100}%`,
|
||||
);
|
||||
el.style.setProperty(
|
||||
"--glow-y",
|
||||
`${((e.clientY - r.top) / r.height) * 100}%`,
|
||||
);
|
||||
};
|
||||
|
||||
const handleEnter = () => {
|
||||
el.style.setProperty("--glow-intensity", "1");
|
||||
for (let i = 0; i < 8; i++) {
|
||||
const timeout = setTimeout(() => {
|
||||
if (!el) return;
|
||||
const p = createParticleElement(
|
||||
Math.random() * el.offsetWidth,
|
||||
Math.random() * el.offsetHeight,
|
||||
glowColor,
|
||||
);
|
||||
el.appendChild(p);
|
||||
particlesRef.current.push(p);
|
||||
gsap.fromTo(
|
||||
p,
|
||||
{ scale: 0, opacity: 0 },
|
||||
{ scale: 1, opacity: 1, duration: 0.3 },
|
||||
);
|
||||
gsap.to(p, {
|
||||
x: "+=" + (Math.random() - 0.5) * 40,
|
||||
y: "+=" + (Math.random() - 0.5) * 40,
|
||||
duration: 1.5 + Math.random(),
|
||||
repeat: -1,
|
||||
yoyo: true,
|
||||
ease: "sine.inOut",
|
||||
});
|
||||
}, i * 100);
|
||||
timeoutsRef.current.push(timeout);
|
||||
}
|
||||
};
|
||||
|
||||
const handleLeave = () => {
|
||||
el.style.setProperty("--glow-intensity", "0");
|
||||
clearParticles();
|
||||
};
|
||||
|
||||
el.addEventListener("mousemove", handleMove);
|
||||
el.addEventListener("mouseenter", handleEnter);
|
||||
el.addEventListener("mouseleave", handleLeave);
|
||||
return () => {
|
||||
el.removeEventListener("mousemove", handleMove);
|
||||
el.removeEventListener("mouseenter", handleEnter);
|
||||
el.removeEventListener("mouseleave", handleLeave);
|
||||
clearParticles();
|
||||
};
|
||||
}, [glowColor, clearParticles]);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={cardRef}
|
||||
onClick={onClick}
|
||||
className={`${className} cursor-target`}
|
||||
style={style}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default function MagicBento({
|
||||
enableBorderGlow = true,
|
||||
glowColor = DEFAULT_GLOW_COLOR,
|
||||
}) {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleCardClick = (link) => {
|
||||
if (link.startsWith("http")) window.open(link, "_blank");
|
||||
else navigate(link);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="card-grid bento-section">
|
||||
{cardData.map((card, i) => (
|
||||
<ParticleCard
|
||||
key={i}
|
||||
onClick={() => handleCardClick(card.link)}
|
||||
className={`magic-bento-card ${enableBorderGlow ? "magic-bento-card--border-glow" : ""}`}
|
||||
glowColor={glowColor}
|
||||
style={{
|
||||
backgroundImage: card.image ? `url(${card.image})` : "none",
|
||||
backgroundColor: card.color || "#060010",
|
||||
}}
|
||||
>
|
||||
{card.image && <div className="magic-bento-card-overlay" />}
|
||||
<div className="magic-bento-card__header">
|
||||
<div className="magic-bento-card__label">{card.label}</div>
|
||||
</div>
|
||||
<div className="magic-bento-card__content">
|
||||
<h3 className="magic-bento-card__title">{card.title}</h3>
|
||||
<p className="magic-bento-card__description">
|
||||
{card.description}
|
||||
</p>
|
||||
</div>
|
||||
</ParticleCard>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
"use client";
|
||||
|
||||
import React, { useRef, useEffect, useCallback } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { gsap } from "gsap";
|
||||
|
||||
// --- Interfaces ---
|
||||
export interface CardDataItem {
|
||||
title: string;
|
||||
image: string;
|
||||
description: string;
|
||||
label: string;
|
||||
link: string;
|
||||
color?: string;
|
||||
}
|
||||
|
||||
export interface MagicBentoProps {
|
||||
enableStars?: boolean;
|
||||
enableSpotlight?: boolean;
|
||||
enableBorderGlow?: boolean;
|
||||
enableTilt?: boolean;
|
||||
enableMagnetism?: boolean;
|
||||
clickEffect?: boolean;
|
||||
spotlightRadius?: number;
|
||||
particleCount?: number;
|
||||
glowColor?: string;
|
||||
disableAnimations?: boolean;
|
||||
}
|
||||
|
||||
const DEFAULT_GLOW_COLOR = "183, 28, 28";
|
||||
|
||||
const cardData: CardDataItem[] = [
|
||||
{
|
||||
title: "Metz Campus",
|
||||
image: "/images/MC.png",
|
||||
description: "Web platform for students.",
|
||||
label: "Web site",
|
||||
link: "https://metzcampus.fr",
|
||||
},
|
||||
{
|
||||
title: "Neo Tokyo Rush",
|
||||
image: "/images/NTR.png",
|
||||
description: "Cyberpunk beat 'em All.",
|
||||
label: "Gamedev",
|
||||
link: "/projects/neo-tokyo-rush",
|
||||
},
|
||||
{
|
||||
title: "About Co Hai Se",
|
||||
image: "/images/Cohaise.jpg",
|
||||
description: "Crafting the Web of Your Ambitions.",
|
||||
label: "Identity",
|
||||
link: "/cohaise",
|
||||
},
|
||||
{
|
||||
title: "Contact",
|
||||
image: "/images/Contact.jpg",
|
||||
description: "Reach out to me.",
|
||||
label: "Network",
|
||||
link: "/contact",
|
||||
},
|
||||
{
|
||||
title: "Затишок",
|
||||
image: "/images/Zatyshok.png",
|
||||
description: "Moodboard developed with love.",
|
||||
label: "Desktop App",
|
||||
link: "/projects/zatyshok",
|
||||
},
|
||||
{
|
||||
title: "Shadow Purge",
|
||||
image: "/images/SPRotD.png",
|
||||
description: "Hack n'slash RPG.",
|
||||
label: "Gamedev",
|
||||
link: "/projects/shadow-purge",
|
||||
},
|
||||
];
|
||||
|
||||
const createParticle = (x: number, y: number, color: string) => {
|
||||
const el = document.createElement("div");
|
||||
el.className = "absolute w-1 h-1 rounded-full pointer-events-none z-50";
|
||||
el.style.backgroundColor = `rgb(${color})`;
|
||||
el.style.boxShadow = `0 0 6px rgba(${color}, 0.8)`;
|
||||
el.style.left = `${x}px`;
|
||||
el.style.top = `${y}px`;
|
||||
return el;
|
||||
};
|
||||
|
||||
const ParticleCard: React.FC<{
|
||||
card: CardDataItem;
|
||||
glowColor: string;
|
||||
enableBorderGlow: boolean;
|
||||
enableTilt: boolean;
|
||||
enableMagnetism: boolean;
|
||||
onClick: (link: string) => void;
|
||||
className?: string;
|
||||
}> = ({
|
||||
card,
|
||||
glowColor,
|
||||
enableBorderGlow,
|
||||
enableTilt,
|
||||
enableMagnetism,
|
||||
onClick,
|
||||
className,
|
||||
}) => {
|
||||
const cardRef = useRef<HTMLDivElement>(null);
|
||||
const particlesRef = useRef<HTMLDivElement[]>([]);
|
||||
|
||||
const clearParticles = useCallback(() => {
|
||||
particlesRef.current.forEach((p) => {
|
||||
gsap.to(p, {
|
||||
opacity: 0,
|
||||
scale: 0,
|
||||
duration: 0.3,
|
||||
onComplete: () => p.remove(),
|
||||
});
|
||||
});
|
||||
particlesRef.current = [];
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const el = cardRef.current;
|
||||
if (!el) return;
|
||||
|
||||
const handleMouseMove = (e: MouseEvent) => {
|
||||
const rect = el.getBoundingClientRect();
|
||||
const x = e.clientX - rect.left;
|
||||
const y = e.clientY - rect.top;
|
||||
|
||||
el.style.setProperty("--glow-x", `${(x / rect.width) * 100}%`);
|
||||
el.style.setProperty("--glow-y", `${(y / rect.height) * 100}%`);
|
||||
|
||||
if (enableTilt) {
|
||||
const rotateX = ((y - rect.height / 2) / (rect.height / 2)) * -5;
|
||||
const rotateY = ((x - rect.width / 2) / (rect.width / 2)) * 5;
|
||||
gsap.to(el, { rotateX, rotateY, duration: 0.2 });
|
||||
}
|
||||
|
||||
if (enableMagnetism) {
|
||||
gsap.to(el, {
|
||||
x: (x - rect.width / 2) * 0.1,
|
||||
y: (y - rect.height / 2) * 0.1,
|
||||
duration: 0.3,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleMouseEnter = () => {
|
||||
el.style.setProperty("--glow-intensity", "1");
|
||||
for (let i = 0; i < 6; i++) {
|
||||
const p = createParticle(
|
||||
Math.random() * el.offsetWidth,
|
||||
Math.random() * el.offsetHeight,
|
||||
glowColor,
|
||||
);
|
||||
el.appendChild(p);
|
||||
particlesRef.current.push(p);
|
||||
gsap.fromTo(
|
||||
p,
|
||||
{ scale: 0, opacity: 0 },
|
||||
{ scale: 1, opacity: 1, duration: 0.3 },
|
||||
);
|
||||
gsap.to(p, {
|
||||
x: "+=" + (Math.random() - 0.5) * 50,
|
||||
y: "+=" + (Math.random() - 0.5) * 50,
|
||||
duration: 1.5 + Math.random(),
|
||||
repeat: -1,
|
||||
yoyo: true,
|
||||
ease: "sine.inOut",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleMouseLeave = () => {
|
||||
el.style.setProperty("--glow-intensity", "0");
|
||||
gsap.to(el, { rotateX: 0, rotateY: 0, x: 0, y: 0, duration: 0.5 });
|
||||
clearParticles();
|
||||
};
|
||||
|
||||
el.addEventListener("mousemove", handleMouseMove);
|
||||
el.addEventListener("mouseenter", handleMouseEnter);
|
||||
el.addEventListener("mouseleave", handleMouseLeave);
|
||||
return () => {
|
||||
el.removeEventListener("mousemove", handleMouseMove);
|
||||
el.removeEventListener("mouseenter", handleMouseEnter);
|
||||
el.removeEventListener("mouseleave", handleMouseLeave);
|
||||
clearParticles();
|
||||
};
|
||||
}, [glowColor, enableTilt, enableMagnetism, clearParticles]);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={cardRef}
|
||||
onClick={() => onClick(card.link)}
|
||||
className={`cursor-target group relative flex flex-col justify-between aspect-4/3 min-h-55 w-full p-6 rounded-[20px] border border-[#1a0505] bg-[#050000] bg-cover bg-center overflow-hidden transition-all duration-300 z-10 hover:-translate-y-1 hover:shadow-[0_0_30px_rgba(183,28,28,0.2)] ${className}`}
|
||||
style={{
|
||||
backgroundImage: `url(${card.image})`,
|
||||
transformStyle: "preserve-3d",
|
||||
}}
|
||||
>
|
||||
<div className="absolute inset-0 bg-linear-to-b from-black/40 to-black/80 z-0 pointer-events-none" />
|
||||
|
||||
{enableBorderGlow && (
|
||||
<div
|
||||
className="absolute inset-0 pointer-events-none transition-opacity duration-300 z-10"
|
||||
style={
|
||||
{
|
||||
opacity: "var(--glow-intensity, 0)",
|
||||
padding: "6px",
|
||||
borderRadius: "20px",
|
||||
background: `radial-gradient(500px circle at var(--glow-x, 50%) var(--glow-y, 50%), rgba(${glowColor}, 1) 0%, rgba(${glowColor}, 0.4) 50%, transparent 80%)`,
|
||||
WebkitMask:
|
||||
"linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
|
||||
WebkitMaskComposite: "xor",
|
||||
maskComposite: "exclude",
|
||||
} as React.CSSProperties
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className="relative z-20 pointer-events-none">
|
||||
<span className="text-xs font-bold text-[#b71c1c] uppercase tracking-[2px]">
|
||||
{card.label}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="relative z-20 opacity-100 pointer-events-none">
|
||||
<h3 className="text-xl font-semibold text-white mt-2">{card.title}</h3>
|
||||
<p className="text-sm text-white/70 leading-relaxed mt-1">
|
||||
{card.description}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default function MagicBento({
|
||||
enableBorderGlow = true,
|
||||
glowColor = DEFAULT_GLOW_COLOR,
|
||||
enableTilt = true,
|
||||
enableMagnetism = true,
|
||||
}: MagicBentoProps) {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleCardClick = (link: string) => {
|
||||
if (link.startsWith("http")) window.open(link, "_blank");
|
||||
else navigate(link);
|
||||
};
|
||||
|
||||
const spanClasses = [
|
||||
"col-span-1",
|
||||
"lg:col-span-1",
|
||||
"lg:col-span-2 lg:row-span-2",
|
||||
"lg:col-span-2 lg:row-span-2 lg:col-start-1 lg:row-start-2",
|
||||
"col-span-1",
|
||||
"lg:col-start-4 lg:row-start-3",
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="w-full max-w-260 mx-auto p-4">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3">
|
||||
{cardData.map((card, i) => (
|
||||
<ParticleCard
|
||||
key={i}
|
||||
card={card}
|
||||
className={spanClasses[i] || ""}
|
||||
glowColor={glowColor}
|
||||
enableBorderGlow={enableBorderGlow}
|
||||
enableTilt={enableTilt}
|
||||
enableMagnetism={enableMagnetism}
|
||||
onClick={handleCardClick}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
export const WebService = () => (
|
||||
<div className="service-detail-content">
|
||||
<h3>Modern & Fast Websites</h3>
|
||||
<p>
|
||||
Building clean, responsive websites using Next.js and React. I focus on
|
||||
speed, visibility, and converting visitors into clients.
|
||||
</p>
|
||||
<ul>
|
||||
<li>Showcase Websites (Landing Pages)</li>
|
||||
<li>SEO & Performance Optimization</li>
|
||||
<li>CMS Integration (Content Management)</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
|
||||
export const MobileService = () => (
|
||||
<div className="service-detail-content">
|
||||
<h3>iOS & Android Apps</h3>
|
||||
<p>
|
||||
Turning your ideas into real mobile apps. Using React Native to create
|
||||
smooth experiences that work perfectly on all phones.
|
||||
</p>
|
||||
<ul>
|
||||
<li>Cross-Platform Apps</li>
|
||||
<li>App Store Submission Help</li>
|
||||
<li>User-Friendly Interfaces</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
|
||||
export const DesignService = () => (
|
||||
<div className="service-detail-content">
|
||||
<h3>UI/UX Design</h3>
|
||||
<p>
|
||||
Simple and effective designs. I create interfaces that look good and help
|
||||
users find what they need effortlessly.
|
||||
</p>
|
||||
<ul>
|
||||
<li>Wireframing & Prototyping</li>
|
||||
<li>Mobile-First Design</li>
|
||||
<li>Visual Identity Basics</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
|
||||
export const SoftwareService = () => (
|
||||
<div className="service-detail-content">
|
||||
<h3>Custom Solutions</h3>
|
||||
<p>
|
||||
Need something specific? I build custom tools and dashboards to help
|
||||
automate your daily tasks and save you time.
|
||||
</p>
|
||||
<ul>
|
||||
<li>Custom Web Tools</li>
|
||||
<li>Desktop Web App</li>
|
||||
<li>Dashboard Creation</li>
|
||||
<li>API Connections</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
@@ -0,0 +1,77 @@
|
||||
import React from "react";
|
||||
|
||||
// Un sous-composant pour éviter de répéter le style des tags/li
|
||||
const ServiceTag = ({ children }: { children: React.ReactNode }) => (
|
||||
<li className="px-6 py-2.5 border border-white/15 rounded-full text-[0.9rem] uppercase tracking-wider text-white bg-transparent transition-all duration-300 hover:bg-white hover:text-black hover:border-white cursor-default">
|
||||
{children}
|
||||
</li>
|
||||
);
|
||||
|
||||
export const WebService = () => (
|
||||
<div className="flex flex-col gap-6">
|
||||
<h3 className="text-2xl font-normal text-white uppercase tracking-[2px] opacity-80 mb-6">
|
||||
Modern & Fast Websites
|
||||
</h3>
|
||||
<p className="text-white/50 text-xl leading-relaxed max-w-200">
|
||||
Building clean, responsive websites using Next.js and React. I focus on
|
||||
speed, visibility, and converting visitors into clients.
|
||||
</p>
|
||||
<ul className="flex flex-wrap gap-4 mt-12 p-0 list-none">
|
||||
<ServiceTag>Showcase Websites (Landing Pages)</ServiceTag>
|
||||
<ServiceTag>SEO & Performance Optimization</ServiceTag>
|
||||
<ServiceTag>CMS Integration (Content Management)</ServiceTag>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
|
||||
export const MobileService = () => (
|
||||
<div className="flex flex-col gap-6">
|
||||
<h3 className="text-2xl font-normal text-white uppercase tracking-[2px] opacity-80 mb-6">
|
||||
iOS & Android Apps
|
||||
</h3>
|
||||
<p className="text-white/50 text-xl leading-relaxed max-w-200">
|
||||
Turning your ideas into real mobile apps. Using React Native to create
|
||||
smooth experiences that work perfectly on all phones.
|
||||
</p>
|
||||
<ul className="flex flex-wrap gap-4 mt-12 p-0 list-none">
|
||||
<ServiceTag>Cross-Platform Apps</ServiceTag>
|
||||
<ServiceTag>App Store Submission Help</ServiceTag>
|
||||
<ServiceTag>User-Friendly Interfaces</ServiceTag>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
|
||||
export const DesignService = () => (
|
||||
<div className="flex flex-col gap-6">
|
||||
<h3 className="text-2xl font-normal text-white uppercase tracking-[2px] opacity-80 mb-6">
|
||||
UI/UX Design
|
||||
</h3>
|
||||
<p className="text-white/50 text-xl leading-relaxed max-w-200">
|
||||
Simple and effective designs. I create interfaces that look good and help
|
||||
users find what they need effortlessly.
|
||||
</p>
|
||||
<ul className="flex flex-wrap gap-4 mt-12 p-0 list-none">
|
||||
<ServiceTag>Wireframing & Prototyping</ServiceTag>
|
||||
<ServiceTag>Mobile-First Design</ServiceTag>
|
||||
<ServiceTag>Visual Identity Basics</ServiceTag>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
|
||||
export const SoftwareService = () => (
|
||||
<div className="flex flex-col gap-6">
|
||||
<h3 className="text-2xl font-normal text-white uppercase tracking-[2px] opacity-80 mb-6">
|
||||
Custom Solutions
|
||||
</h3>
|
||||
<p className="text-white/50 text-xl leading-relaxed max-w-200">
|
||||
Need something specific? I build custom tools and dashboards to help
|
||||
automate your daily tasks and save you time.
|
||||
</p>
|
||||
<ul className="flex flex-wrap gap-4 mt-12 p-0 list-none">
|
||||
<ServiceTag>Custom Web Tools</ServiceTag>
|
||||
<ServiceTag>Desktop Web App</ServiceTag>
|
||||
<ServiceTag>Dashboard Creation</ServiceTag>
|
||||
<ServiceTag>API Connections</ServiceTag>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
File diff suppressed because it is too large
Load Diff
-2
@@ -11,7 +11,6 @@ export default function BackgroundWrapper() {
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* 1. COUCHE CURSEURS */}
|
||||
<div
|
||||
className="fixed inset-0 pointer-events-none"
|
||||
style={{
|
||||
@@ -30,7 +29,6 @@ export default function BackgroundWrapper() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 2. COUCHE BACKGROUNDS */}
|
||||
<div
|
||||
className="fixed inset-0 bg-[#0e0e11] pointer-events-none"
|
||||
style={{ zIndex: -10 }}
|
||||
@@ -1,12 +1,11 @@
|
||||
import { Renderer, Program, Mesh, Color, Triangle } from "ogl";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
// --- SHADERS (Inchangés) ---
|
||||
const vertexShader = `
|
||||
attribute vec2 uv;
|
||||
attribute vec2 position;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
vUv = uv;
|
||||
gl_Position = vec4(position, 0, 1);
|
||||
@@ -15,7 +14,6 @@ void main() {
|
||||
|
||||
const fragmentShader = `
|
||||
precision highp float;
|
||||
|
||||
uniform float uTime;
|
||||
uniform vec3 uResolution;
|
||||
uniform vec2 uFocal;
|
||||
@@ -34,7 +32,6 @@ uniform float uRepulsionStrength;
|
||||
uniform float uMouseActiveFactor;
|
||||
uniform float uAutoCenterRepulsion;
|
||||
uniform bool uTransparent;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
#define NUM_LAYER 4.0
|
||||
@@ -47,91 +44,70 @@ float Hash21(vec2 p) {
|
||||
p += dot(p, p + 45.32);
|
||||
return fract(p.x * p.y);
|
||||
}
|
||||
|
||||
float tri(float x) {
|
||||
return abs(fract(x) * 2.0 - 1.0);
|
||||
}
|
||||
|
||||
float tri(float x) { return abs(fract(x) * 2.0 - 1.0); }
|
||||
float tris(float x) {
|
||||
float t = fract(x);
|
||||
return 1.0 - smoothstep(0.0, 1.0, abs(2.0 * t - 1.0));
|
||||
}
|
||||
|
||||
float trisn(float x) {
|
||||
float t = fract(x);
|
||||
return 2.0 * (1.0 - smoothstep(0.0, 1.0, abs(2.0 * t - 1.0))) - 1.0;
|
||||
}
|
||||
|
||||
vec3 hsv2rgb(vec3 c) {
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
|
||||
float Star(vec2 uv, float flare) {
|
||||
float Star(vec2 uv, float flare, float glow) {
|
||||
float d = length(uv);
|
||||
float m = (0.05 * uGlowIntensity) / d;
|
||||
float m = (0.05 * glow) / d;
|
||||
float rays = smoothstep(0.0, 1.0, 1.0 - abs(uv.x * uv.y * 1000.0));
|
||||
m += rays * flare * uGlowIntensity;
|
||||
m += rays * flare * glow;
|
||||
uv *= MAT45;
|
||||
rays = smoothstep(0.0, 1.0, 1.0 - abs(uv.x * uv.y * 1000.0));
|
||||
m += rays * 0.3 * flare * uGlowIntensity;
|
||||
m += rays * 0.3 * flare * glow;
|
||||
m *= smoothstep(1.0, 0.2, d);
|
||||
return m;
|
||||
}
|
||||
|
||||
vec3 StarLayer(vec2 uv) {
|
||||
vec3 StarLayer(vec2 uv, float time, float speed, float starSpeed, float hueShift, float saturation, float glow, float twinkleIntensity) {
|
||||
vec3 col = vec3(0.0);
|
||||
|
||||
vec2 gv = fract(uv) - 0.5;
|
||||
vec2 id = floor(uv);
|
||||
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
vec2 offset = vec2(float(x), float(y));
|
||||
vec2 si = id + vec2(float(x), float(y));
|
||||
vec2 si = id + offset;
|
||||
float seed = Hash21(si);
|
||||
float size = fract(seed * 345.32);
|
||||
float glossLocal = tri(uStarSpeed / (PERIOD * seed + 1.0));
|
||||
float glossLocal = tri(starSpeed / (PERIOD * seed + 1.0));
|
||||
float flareSize = smoothstep(0.9, 1.0, size) * glossLocal;
|
||||
|
||||
float red = smoothstep(STAR_COLOR_CUTOFF, 1.0, Hash21(si + 1.0)) + STAR_COLOR_CUTOFF;
|
||||
float blu = smoothstep(STAR_COLOR_CUTOFF, 1.0, Hash21(si + 3.0)) + STAR_COLOR_CUTOFF;
|
||||
float grn = min(red, blu) * seed;
|
||||
vec3 base = vec3(red, grn, blu);
|
||||
|
||||
float hue = atan(base.g - base.r, base.b - base.r) / (2.0 * 3.14159) + 0.5;
|
||||
hue = fract(hue + uHueShift / 360.0);
|
||||
float sat = length(base - vec3(dot(base, vec3(0.299, 0.587, 0.114)))) * uSaturation;
|
||||
hue = fract(hue + hueShift / 360.0);
|
||||
float sat = length(base - vec3(dot(base, vec3(0.299, 0.587, 0.114)))) * saturation;
|
||||
float val = max(max(base.r, base.g), base.b);
|
||||
base = hsv2rgb(vec3(hue, sat, val));
|
||||
|
||||
vec2 pad = vec2(tris(seed * 34.0 + uTime * uSpeed / 10.0), tris(seed * 38.0 + uTime * uSpeed / 30.0)) - 0.5;
|
||||
|
||||
float star = Star(gv - offset - pad, flareSize);
|
||||
vec3 color = base;
|
||||
|
||||
float twinkle = trisn(uTime * uSpeed + seed * 6.2831) * 0.5 + 1.0;
|
||||
twinkle = mix(1.0, twinkle, uTwinkleIntensity);
|
||||
star *= twinkle;
|
||||
|
||||
col += star * size * color;
|
||||
vec2 pad = vec2(tris(seed * 34.0 + time * speed / 10.0), tris(seed * 38.0 + time * speed / 30.0)) - 0.5;
|
||||
float star = Star(gv - offset - pad, flareSize, glow);
|
||||
float twinkle = trisn(time * speed + seed * 6.2831) * 0.5 + 1.0;
|
||||
twinkle = mix(1.0, twinkle, twinkleIntensity);
|
||||
col += star * size * base * twinkle;
|
||||
}
|
||||
}
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 focalPx = uFocal * uResolution.xy;
|
||||
vec2 uv = (vUv * uResolution.xy - focalPx) / uResolution.y;
|
||||
|
||||
vec2 mouseNorm = uMouse - vec2(0.5);
|
||||
|
||||
if (uAutoCenterRepulsion > 0.0) {
|
||||
vec2 centerUV = vec2(0.0, 0.0);
|
||||
float centerDist = length(uv - centerUV);
|
||||
vec2 repulsion = normalize(uv - centerUV) * (uAutoCenterRepulsion / (centerDist + 0.1));
|
||||
float centerDist = length(uv);
|
||||
vec2 repulsion = normalize(uv) * (uAutoCenterRepulsion / (centerDist + 0.1));
|
||||
uv += repulsion * 0.05;
|
||||
} else if (uMouseRepulsion) {
|
||||
vec2 mousePosUV = (uMouse * uResolution.xy - focalPx) / uResolution.y;
|
||||
@@ -139,36 +115,49 @@ void main() {
|
||||
vec2 repulsion = normalize(uv - mousePosUV) * (uRepulsionStrength / (mouseDist + 0.1));
|
||||
uv += repulsion * 0.05 * uMouseActiveFactor;
|
||||
} else {
|
||||
vec2 mouseOffset = mouseNorm * 0.1 * uMouseActiveFactor;
|
||||
uv += mouseOffset;
|
||||
uv += mouseNorm * 0.1 * uMouseActiveFactor;
|
||||
}
|
||||
|
||||
float autoRotAngle = uTime * uRotationSpeed;
|
||||
mat2 autoRot = mat2(cos(autoRotAngle), -sin(autoRotAngle), sin(autoRotAngle), cos(autoRotAngle));
|
||||
uv = autoRot * uv;
|
||||
|
||||
uv = mat2(uRotation.x, -uRotation.y, uRotation.y, uRotation.x) * uv;
|
||||
|
||||
vec3 col = vec3(0.0);
|
||||
|
||||
for (float i = 0.0; i < 1.0; i += 1.0 / NUM_LAYER) {
|
||||
float depth = fract(i + uStarSpeed * uSpeed);
|
||||
float scale = mix(20.0 * uDensity, 0.5 * uDensity, depth);
|
||||
float fade = depth * smoothstep(1.0, 0.9, depth);
|
||||
col += StarLayer(uv * scale + i * 453.32) * fade;
|
||||
col += StarLayer(uv * scale + i * 453.32, uTime, uSpeed, uStarSpeed, uHueShift, uSaturation, uGlowIntensity, uTwinkleIntensity) * fade;
|
||||
}
|
||||
|
||||
if (uTransparent) {
|
||||
float alpha = length(col);
|
||||
alpha = smoothstep(0.0, 0.3, alpha);
|
||||
alpha = min(alpha, 1.0);
|
||||
gl_FragColor = vec4(col, alpha);
|
||||
float alpha = smoothstep(0.0, 0.3, length(col));
|
||||
gl_FragColor = vec4(col, min(alpha, 1.0));
|
||||
} else {
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
// --- INTERFACE DES PROPS ---
|
||||
interface GalaxyProps {
|
||||
focal?: [number, number];
|
||||
rotation?: [number, number];
|
||||
starSpeed?: number;
|
||||
density?: number;
|
||||
hueShift?: number;
|
||||
disableAnimation?: boolean;
|
||||
speed?: number;
|
||||
mouseInteraction?: boolean;
|
||||
glowIntensity?: number;
|
||||
saturation?: number;
|
||||
mouseRepulsion?: boolean;
|
||||
repulsionStrength?: number;
|
||||
twinkleIntensity?: number;
|
||||
rotationSpeed?: number;
|
||||
autoCenterRepulsion?: number;
|
||||
transparent?: boolean;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export default function Galaxy({
|
||||
focal = [0.5, 0.5],
|
||||
rotation = [0.5, 0.5],
|
||||
@@ -187,8 +176,9 @@ export default function Galaxy({
|
||||
autoCenterRepulsion = 10,
|
||||
transparent = true,
|
||||
...rest
|
||||
}) {
|
||||
const ctnDom = useRef(null);
|
||||
}: GalaxyProps) {
|
||||
const ctnDom = useRef<HTMLDivElement>(null);
|
||||
const [opacity, setOpacity] = useState(0);
|
||||
const targetMousePos = useRef({ x: 0.5, y: 0.5 });
|
||||
const smoothMousePos = useRef({ x: 0.5, y: 0.5 });
|
||||
const targetMouseActive = useRef(0.0);
|
||||
@@ -197,6 +187,7 @@ export default function Galaxy({
|
||||
useEffect(() => {
|
||||
if (!ctnDom.current) return;
|
||||
const ctn = ctnDom.current;
|
||||
|
||||
const renderer = new Renderer({
|
||||
alpha: transparent,
|
||||
premultipliedAlpha: false,
|
||||
@@ -206,16 +197,13 @@ export default function Galaxy({
|
||||
if (transparent) {
|
||||
gl.enable(gl.BLEND);
|
||||
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
||||
gl.clearColor(0, 0, 0, 0);
|
||||
} else {
|
||||
gl.clearColor(0, 0, 0, 1);
|
||||
}
|
||||
|
||||
let program;
|
||||
let program: Program;
|
||||
|
||||
function resize() {
|
||||
const scale = 1;
|
||||
renderer.setSize(ctn.offsetWidth * scale, ctn.offsetHeight * scale);
|
||||
if (!ctn) return;
|
||||
renderer.setSize(ctn.offsetWidth, ctn.offsetHeight);
|
||||
if (program) {
|
||||
program.uniforms.uResolution.value = new Color(
|
||||
gl.canvas.width,
|
||||
@@ -224,8 +212,8 @@ export default function Galaxy({
|
||||
);
|
||||
}
|
||||
}
|
||||
window.addEventListener("resize", resize, false);
|
||||
resize();
|
||||
|
||||
window.addEventListener("resize", resize);
|
||||
|
||||
const geometry = new Triangle(gl);
|
||||
program = new Program(gl, {
|
||||
@@ -233,25 +221,14 @@ export default function Galaxy({
|
||||
fragment: fragmentShader,
|
||||
uniforms: {
|
||||
uTime: { value: 0 },
|
||||
uResolution: {
|
||||
value: new Color(
|
||||
gl.canvas.width,
|
||||
gl.canvas.height,
|
||||
gl.canvas.width / gl.canvas.height,
|
||||
),
|
||||
},
|
||||
uResolution: { value: new Color(1, 1, 1) },
|
||||
uFocal: { value: new Float32Array(focal) },
|
||||
uRotation: { value: new Float32Array(rotation) },
|
||||
uStarSpeed: { value: starSpeed },
|
||||
uDensity: { value: density },
|
||||
uHueShift: { value: hueShift },
|
||||
uSpeed: { value: speed },
|
||||
uMouse: {
|
||||
value: new Float32Array([
|
||||
smoothMousePos.current.x,
|
||||
smoothMousePos.current.y,
|
||||
]),
|
||||
},
|
||||
uMouse: { value: new Float32Array([0.5, 0.5]) },
|
||||
uGlowIntensity: { value: glowIntensity },
|
||||
uSaturation: { value: saturation },
|
||||
uMouseRepulsion: { value: mouseRepulsion },
|
||||
@@ -264,41 +241,43 @@ export default function Galaxy({
|
||||
},
|
||||
});
|
||||
|
||||
const mesh = new Mesh(gl, { geometry, program });
|
||||
let animateId;
|
||||
resize();
|
||||
|
||||
function update(t) {
|
||||
const mesh = new Mesh(gl, { geometry, program });
|
||||
let animateId: number;
|
||||
|
||||
function update(t: number) {
|
||||
animateId = requestAnimationFrame(update);
|
||||
if (!disableAnimation) {
|
||||
program.uniforms.uTime.value = t * 0.001;
|
||||
program.uniforms.uStarSpeed.value = (t * 0.001 * starSpeed) / 10.0;
|
||||
}
|
||||
|
||||
const lerpFactor = 0.05;
|
||||
const lerp = 0.05;
|
||||
smoothMousePos.current.x +=
|
||||
(targetMousePos.current.x - smoothMousePos.current.x) * lerpFactor;
|
||||
(targetMousePos.current.x - smoothMousePos.current.x) * lerp;
|
||||
smoothMousePos.current.y +=
|
||||
(targetMousePos.current.y - smoothMousePos.current.y) * lerpFactor;
|
||||
|
||||
(targetMousePos.current.y - smoothMousePos.current.y) * lerp;
|
||||
smoothMouseActive.current +=
|
||||
(targetMouseActive.current - smoothMouseActive.current) * lerpFactor;
|
||||
|
||||
(targetMouseActive.current - smoothMouseActive.current) * lerp;
|
||||
program.uniforms.uMouse.value[0] = smoothMousePos.current.x;
|
||||
program.uniforms.uMouse.value[1] = smoothMousePos.current.y;
|
||||
program.uniforms.uMouseActiveFactor.value = smoothMouseActive.current;
|
||||
|
||||
renderer.render({ scene: mesh });
|
||||
}
|
||||
|
||||
animateId = requestAnimationFrame(update);
|
||||
ctn.appendChild(gl.canvas);
|
||||
|
||||
// --- CORRECTION MAJEURE ICI ---
|
||||
function handleMouseMove(e) {
|
||||
// On calcule par rapport à la fenêtre globale
|
||||
const x = e.clientX / window.innerWidth;
|
||||
const y = 1.0 - e.clientY / window.innerHeight;
|
||||
// 2. DÉCLENCHEMENT DU FADE IN
|
||||
const timer = setTimeout(() => {
|
||||
setOpacity(1);
|
||||
}, 100);
|
||||
|
||||
targetMousePos.current = { x, y };
|
||||
function handleMouseMove(e: MouseEvent) {
|
||||
targetMousePos.current = {
|
||||
x: e.clientX / window.innerWidth,
|
||||
y: 1.0 - e.clientY / window.innerHeight,
|
||||
};
|
||||
targetMouseActive.current = 1.0;
|
||||
}
|
||||
|
||||
@@ -307,18 +286,16 @@ export default function Galaxy({
|
||||
}
|
||||
|
||||
return () => {
|
||||
clearTimeout(timer);
|
||||
cancelAnimationFrame(animateId);
|
||||
window.removeEventListener("resize", resize);
|
||||
|
||||
// NETTOYAGE CORRECT : On enlève l'écouteur de window, pas de ctn
|
||||
if (mouseInteraction) {
|
||||
window.removeEventListener("mousemove", handleMouseMove);
|
||||
}
|
||||
|
||||
window.removeEventListener("mousemove", handleMouseMove);
|
||||
const extension = gl.getExtension("WEBGL_lose_context");
|
||||
if (extension) extension.loseContext();
|
||||
if (ctn.contains(gl.canvas)) {
|
||||
ctn.removeChild(gl.canvas);
|
||||
}
|
||||
gl.getExtension("WEBGL_lose_context")?.loseContext();
|
||||
geometry.remove();
|
||||
};
|
||||
}, [
|
||||
focal,
|
||||
@@ -339,5 +316,19 @@ export default function Galaxy({
|
||||
transparent,
|
||||
]);
|
||||
|
||||
return <div ref={ctnDom} className="w-full h-full relative" {...rest} />;
|
||||
return (
|
||||
<div
|
||||
ref={ctnDom}
|
||||
style={{
|
||||
position: "fixed",
|
||||
inset: 0,
|
||||
zIndex: -1,
|
||||
pointerEvents: "none",
|
||||
opacity: opacity,
|
||||
transition: "opacity 1200ms ease-in-out",
|
||||
...rest.style,
|
||||
}}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
.light-pillar-fallback {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
color: #888;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.light-pillar-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
+61
-61
@@ -1,8 +1,23 @@
|
||||
import { useRef, useEffect, useState } from "react";
|
||||
import React, { useRef, useEffect, useState, CSSProperties } from "react";
|
||||
import * as THREE from "three";
|
||||
import "./LightPillar.css";
|
||||
|
||||
const LightPillar = ({
|
||||
interface LightPillarProps {
|
||||
topColor?: string;
|
||||
bottomColor?: string;
|
||||
intensity?: number;
|
||||
rotationSpeed?: number;
|
||||
interactive?: boolean;
|
||||
className?: string;
|
||||
glowAmount?: number;
|
||||
pillarWidth?: number;
|
||||
pillarHeight?: number;
|
||||
noiseIntensity?: number;
|
||||
mixBlendMode?: CSSProperties["mixBlendMode"];
|
||||
pillarRotation?: number;
|
||||
quality?: "low" | "medium" | "high";
|
||||
}
|
||||
|
||||
const LightPillar: React.FC<LightPillarProps> = ({
|
||||
topColor = "#5227FF",
|
||||
bottomColor = "#FF9FFC",
|
||||
intensity = 1.0,
|
||||
@@ -17,15 +32,16 @@ const LightPillar = ({
|
||||
pillarRotation = 0,
|
||||
quality = "high",
|
||||
}) => {
|
||||
const containerRef = useRef(null);
|
||||
const rendererRef = useRef(null);
|
||||
const materialRef = useRef(null);
|
||||
const sceneRef = useRef(null);
|
||||
const cameraRef = useRef(null);
|
||||
const geometryRef = useRef(null);
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const rendererRef = useRef<THREE.WebGLRenderer | null>(null);
|
||||
const materialRef = useRef<THREE.ShaderMaterial | null>(null);
|
||||
const sceneRef = useRef<THREE.Scene | null>(null);
|
||||
const cameraRef = useRef<THREE.OrthographicCamera | null>(null);
|
||||
const geometryRef = useRef<THREE.PlaneGeometry | null>(null);
|
||||
const mouseRef = useRef(new THREE.Vector2(0, 0));
|
||||
const timeRef = useRef(0);
|
||||
const rafRef = useRef(null);
|
||||
const rafRef = useRef<number | null>(null);
|
||||
const [opacity, setOpacity] = useState(0);
|
||||
|
||||
const [webGLSupported, setWebGLSupported] = useState(() => {
|
||||
try {
|
||||
@@ -46,6 +62,8 @@ const LightPillar = ({
|
||||
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
||||
navigator.userAgent,
|
||||
);
|
||||
const effectiveQuality =
|
||||
isMobile && quality === "high" ? "medium" : quality;
|
||||
const effectivelyInteractive = interactive && !isMobile;
|
||||
|
||||
const container = containerRef.current;
|
||||
@@ -57,7 +75,15 @@ const LightPillar = ({
|
||||
const camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
||||
cameraRef.current = camera;
|
||||
|
||||
const qualitySettings = {
|
||||
type QualityConfig = {
|
||||
iterations: number;
|
||||
waveIterations: number;
|
||||
pixelRatio: number;
|
||||
precision: "mediump" | "highp";
|
||||
stepMultiplier: number;
|
||||
};
|
||||
|
||||
const qualitySettings: Record<"low" | "medium" | "high", QualityConfig> = {
|
||||
low: {
|
||||
iterations: 24,
|
||||
waveIterations: 1,
|
||||
@@ -81,14 +107,16 @@ const LightPillar = ({
|
||||
},
|
||||
};
|
||||
|
||||
const settings = qualitySettings[quality] || qualitySettings.medium;
|
||||
const settings =
|
||||
qualitySettings[effectiveQuality] || qualitySettings.medium;
|
||||
|
||||
let renderer;
|
||||
let renderer: THREE.WebGLRenderer;
|
||||
try {
|
||||
renderer = new THREE.WebGLRenderer({
|
||||
antialias: false,
|
||||
alpha: true,
|
||||
powerPreference: quality === "high" ? "high-performance" : "low-power",
|
||||
powerPreference:
|
||||
effectiveQuality === "high" ? "high-performance" : "low-power",
|
||||
precision: settings.precision,
|
||||
stencil: false,
|
||||
depth: false,
|
||||
@@ -97,13 +125,14 @@ const LightPillar = ({
|
||||
setTimeout(() => setWebGLSupported(false), 0);
|
||||
return;
|
||||
}
|
||||
setTimeout(() => setOpacity(1), 100);
|
||||
|
||||
renderer.setSize(width, height);
|
||||
renderer.setPixelRatio(settings.pixelRatio);
|
||||
container.appendChild(renderer.domElement);
|
||||
rendererRef.current = renderer;
|
||||
|
||||
const parseColor = (hex) => {
|
||||
const parseColor = (hex: string) => {
|
||||
const color = new THREE.Color(hex);
|
||||
return new THREE.Vector3(color.r, color.g, color.b);
|
||||
};
|
||||
@@ -144,15 +173,9 @@ const LightPillar = ({
|
||||
void main() {
|
||||
vec2 uv = vUv * 2.0 - 1.0;
|
||||
float aspect = uResolution.x / uResolution.y;
|
||||
|
||||
if (aspect > 1.0) {
|
||||
uv.x *= aspect;
|
||||
} else {
|
||||
uv.y /= aspect;
|
||||
}
|
||||
if (aspect > 1.0) uv.x *= aspect; else uv.y /= aspect;
|
||||
|
||||
uv = vec2(uPillarRotCos * uv.x - uPillarRotSin * uv.y, uPillarRotSin * uv.x + uPillarRotCos * uv.y);
|
||||
|
||||
vec3 ro = vec3(0.0, 0.0, -10.0);
|
||||
vec3 rd = normalize(vec3(uv, 1.0));
|
||||
|
||||
@@ -167,49 +190,36 @@ const LightPillar = ({
|
||||
|
||||
vec3 col = vec3(0.0);
|
||||
float t = 0.1;
|
||||
|
||||
for(int i = 0; i < MAX_ITER; i++) {
|
||||
vec3 p = ro + rd * t;
|
||||
p.xz = vec2(rotC * p.x - rotS * p.z, rotS * p.x + rotC * p.z);
|
||||
vec3 q = p;
|
||||
q.y = p.y * uPillarHeight + uTime;
|
||||
|
||||
float freq = 1.0;
|
||||
float amp = 1.0;
|
||||
|
||||
float freq = 1.0; float amp = 1.0;
|
||||
for(int j = 0; j < WAVE_ITER; j++) {
|
||||
q.xz = vec2(uWaveCos * q.x - uWaveSin * q.z, uWaveSin * q.x + uWaveCos * q.z);
|
||||
q += cos(q.zxy * freq - uTime * float(j) * 2.0) * amp;
|
||||
freq *= 2.0;
|
||||
amp *= 0.5;
|
||||
freq *= 2.0; amp *= 0.5;
|
||||
}
|
||||
|
||||
float d = length(cos(q.xz)) - 0.2;
|
||||
float bound = length(p.xz) - uPillarWidth;
|
||||
float k = 4.0;
|
||||
float h = max(k - abs(d - bound), 0.0);
|
||||
d = max(d, bound) + h * h * 0.0625 / k;
|
||||
d = abs(d) * 0.15 + 0.01;
|
||||
|
||||
float grad = clamp((15.0 - p.y) / 30.0, 0.0, 1.0);
|
||||
col += mix(uBottomColor, uTopColor, grad) / d;
|
||||
|
||||
t += d * STEP_MULT;
|
||||
if(t > 50.0) break;
|
||||
}
|
||||
|
||||
float widthNorm = uPillarWidth / 3.0;
|
||||
col = tanh(col * uGlowAmount / widthNorm);
|
||||
col -= fract(sin(dot(gl_FragCoord.xy, vec2(12.9898, 78.233))) * 43758.5453) / 15.0 * uNoiseIntensity;
|
||||
|
||||
gl_FragColor = vec4(col * uIntensity, 1.0);
|
||||
}
|
||||
`;
|
||||
|
||||
const pillarRotRad = (pillarRotation * Math.PI) / 180;
|
||||
const waveSin = Math.sin(0.4);
|
||||
const waveCos = Math.cos(0.4);
|
||||
|
||||
const material = new THREE.ShaderMaterial({
|
||||
vertexShader,
|
||||
fragmentShader,
|
||||
@@ -229,8 +239,8 @@ const LightPillar = ({
|
||||
uRotSin: { value: 0.0 },
|
||||
uPillarRotCos: { value: Math.cos(pillarRotRad) },
|
||||
uPillarRotSin: { value: Math.sin(pillarRotRad) },
|
||||
uWaveSin: { value: waveSin },
|
||||
uWaveCos: { value: waveCos },
|
||||
uWaveSin: { value: Math.sin(0.4) },
|
||||
uWaveCos: { value: Math.cos(0.4) },
|
||||
},
|
||||
transparent: true,
|
||||
depthWrite: false,
|
||||
@@ -243,21 +253,19 @@ const LightPillar = ({
|
||||
const mesh = new THREE.Mesh(geometry, material);
|
||||
scene.add(mesh);
|
||||
|
||||
const handleMouseMove = (event) => {
|
||||
const handleMouseMove = (event: MouseEvent) => {
|
||||
if (!effectivelyInteractive) return;
|
||||
const x = (event.clientX / window.innerWidth) * 2 - 1;
|
||||
const y = -(event.clientY / window.innerHeight) * 2 + 1;
|
||||
mouseRef.current.set(x, y);
|
||||
};
|
||||
|
||||
if (effectivelyInteractive) {
|
||||
window.addEventListener("mousemove", handleMouseMove, { passive: true });
|
||||
}
|
||||
|
||||
let lastTime = performance.now();
|
||||
const targetFPS = 60;
|
||||
const frameTime = 1000 / targetFPS;
|
||||
|
||||
const animate = (currentTime) => {
|
||||
const animate = (currentTime: number) => {
|
||||
if (
|
||||
!materialRef.current ||
|
||||
!rendererRef.current ||
|
||||
@@ -267,7 +275,7 @@ const LightPillar = ({
|
||||
return;
|
||||
|
||||
const deltaTime = currentTime - lastTime;
|
||||
if (deltaTime >= frameTime) {
|
||||
if (deltaTime >= 16.6) {
|
||||
timeRef.current += 0.016 * rotationSpeed;
|
||||
const t = timeRef.current;
|
||||
materialRef.current.uniforms.uTime.value = t;
|
||||
@@ -275,9 +283,8 @@ const LightPillar = ({
|
||||
materialRef.current.uniforms.uRotCos.value = Math.cos(t * 0.6);
|
||||
materialRef.current.uniforms.uRotSin.value = Math.sin(t * 0.6);
|
||||
}
|
||||
|
||||
rendererRef.current.render(sceneRef.current, cameraRef.current);
|
||||
lastTime = currentTime - (deltaTime % frameTime);
|
||||
lastTime = currentTime - (deltaTime % 16.6);
|
||||
}
|
||||
rafRef.current = requestAnimationFrame(animate);
|
||||
};
|
||||
@@ -296,16 +303,13 @@ const LightPillar = ({
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("resize", handleResize);
|
||||
if (effectivelyInteractive) {
|
||||
if (effectivelyInteractive)
|
||||
window.removeEventListener("mousemove", handleMouseMove);
|
||||
}
|
||||
if (rafRef.current) cancelAnimationFrame(rafRef.current);
|
||||
if (rendererRef.current) {
|
||||
rendererRef.current.dispose();
|
||||
rendererRef.current.forceContextLoss();
|
||||
if (container.contains(rendererRef.current.domElement)) {
|
||||
if (container.contains(rendererRef.current.domElement))
|
||||
container.removeChild(rendererRef.current.domElement);
|
||||
}
|
||||
}
|
||||
if (materialRef.current) materialRef.current.dispose();
|
||||
if (geometryRef.current) geometryRef.current.dispose();
|
||||
@@ -325,28 +329,24 @@ const LightPillar = ({
|
||||
quality,
|
||||
]);
|
||||
|
||||
if (!webGLSupported) {
|
||||
if (!webGLSupported)
|
||||
return (
|
||||
<div
|
||||
className={`light-pillar-fallback ${className}`}
|
||||
className={`w-full h-full absolute inset-0 flex items-center justify-center bg-black/10 text-[#888] text-[14px] ${className}`}
|
||||
style={{ mixBlendMode }}
|
||||
>
|
||||
WebGL not supported
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
className={`light-pillar-container ${className}`}
|
||||
className={`w-full h-full absolute inset-0 transition-opacity duration-1000 ${className}`}
|
||||
style={{
|
||||
mixBlendMode,
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
pointerEvents: "none",
|
||||
opacity: opacity,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,57 +0,0 @@
|
||||
.target-cursor-wrapper {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
pointer-events: none;
|
||||
z-index: 9999;
|
||||
mix-blend-mode: difference;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.target-cursor-dot {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
background: #fff;
|
||||
border-radius: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.target-cursor-corner {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border: 3px solid #fff;
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.corner-tl {
|
||||
transform: translate(-150%, -150%);
|
||||
border-right: none;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.corner-tr {
|
||||
transform: translate(50%, -150%);
|
||||
border-left: none;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.corner-br {
|
||||
transform: translate(50%, 50%);
|
||||
border-left: none;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.corner-bl {
|
||||
transform: translate(-150%, 50%);
|
||||
border-right: none;
|
||||
border-top: none;
|
||||
}
|
||||
@@ -1,51 +1,50 @@
|
||||
import { useEffect, useRef, useCallback, useMemo } from "react";
|
||||
import React, { useEffect, useRef, useCallback, useMemo } from "react";
|
||||
import { gsap } from "gsap";
|
||||
import "./TargetCursor.css";
|
||||
|
||||
const TargetCursor = ({
|
||||
export interface TargetCursorProps {
|
||||
targetSelector?: string;
|
||||
spinDuration?: number;
|
||||
hideDefaultCursor?: boolean;
|
||||
hoverDuration?: number;
|
||||
parallaxOn?: boolean;
|
||||
}
|
||||
|
||||
const TargetCursor: React.FC<TargetCursorProps> = ({
|
||||
targetSelector = ".cursor-target",
|
||||
spinDuration = 2,
|
||||
hideDefaultCursor = true,
|
||||
hoverDuration = 0.2,
|
||||
parallaxOn = true,
|
||||
}) => {
|
||||
const cursorRef = useRef(null);
|
||||
const cornersRef = useRef(null);
|
||||
const spinTl = useRef(null);
|
||||
const dotRef = useRef(null);
|
||||
const cursorRef = useRef<HTMLDivElement>(null);
|
||||
const cornersRef = useRef<NodeListOf<HTMLDivElement> | null>(null);
|
||||
const spinTl = useRef<gsap.core.Timeline | null>(null);
|
||||
const dotRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const isActiveRef = useRef(false);
|
||||
const targetCornerPositionsRef = useRef(null);
|
||||
const tickerFnRef = useRef(null);
|
||||
const activeStrengthRef = useRef(0);
|
||||
const targetCornerPositionsRef = useRef<{ x: number; y: number }[] | null>(
|
||||
null,
|
||||
);
|
||||
const tickerFnRef = useRef<(() => void) | null>(null);
|
||||
const activeStrengthRef = useRef({ current: 0 });
|
||||
|
||||
const isMobile = useMemo(() => {
|
||||
const hasTouchScreen =
|
||||
"ontouchstart" in window || navigator.maxTouchPoints > 0;
|
||||
const isSmallScreen = window.innerWidth <= 768;
|
||||
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
|
||||
const userAgent =
|
||||
navigator.userAgent || navigator.vendor || (window as any).opera;
|
||||
const mobileRegex =
|
||||
/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i;
|
||||
const isMobileUserAgent = mobileRegex.test(userAgent.toLowerCase());
|
||||
return (hasTouchScreen && isSmallScreen) || isMobileUserAgent;
|
||||
}, []);
|
||||
|
||||
const constants = useMemo(
|
||||
() => ({
|
||||
borderWidth: 3,
|
||||
cornerSize: 12,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
const constants = useMemo(() => ({ borderWidth: 3, cornerSize: 12 }), []);
|
||||
|
||||
const moveCursor = useCallback((x, y) => {
|
||||
const moveCursor = useCallback((x: number, y: number) => {
|
||||
if (!cursorRef.current) return;
|
||||
gsap.to(cursorRef.current, {
|
||||
x,
|
||||
y,
|
||||
duration: 0.1,
|
||||
ease: "power3.out",
|
||||
});
|
||||
gsap.to(cursorRef.current, { x, y, duration: 0.1, ease: "power3.out" });
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -57,13 +56,15 @@ const TargetCursor = ({
|
||||
}
|
||||
|
||||
const cursor = cursorRef.current;
|
||||
cornersRef.current = cursor.querySelectorAll(".target-cursor-corner");
|
||||
cornersRef.current = cursor.querySelectorAll<HTMLDivElement>(
|
||||
".target-cursor-corner",
|
||||
);
|
||||
|
||||
let activeTarget = null;
|
||||
let currentLeaveHandler = null;
|
||||
let resumeTimeout = null;
|
||||
let activeTarget: Element | null = null;
|
||||
let currentLeaveHandler: (() => void) | null = null;
|
||||
let resumeTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
const cleanupTarget = (target) => {
|
||||
const cleanupTarget = (target: Element) => {
|
||||
if (currentLeaveHandler) {
|
||||
target.removeEventListener("mouseleave", currentLeaveHandler);
|
||||
}
|
||||
@@ -81,13 +82,11 @@ const TargetCursor = ({
|
||||
if (spinTl.current) {
|
||||
spinTl.current.kill();
|
||||
}
|
||||
spinTl.current = gsap
|
||||
.timeline({ repeat: -1 })
|
||||
.to(cursor, {
|
||||
rotation: "+=360",
|
||||
duration: spinDuration,
|
||||
ease: "none",
|
||||
});
|
||||
spinTl.current = gsap.timeline({ repeat: -1 }).to(cursor, {
|
||||
rotation: "+=360",
|
||||
duration: spinDuration,
|
||||
ease: "none",
|
||||
});
|
||||
};
|
||||
|
||||
createSpinTimeline();
|
||||
@@ -100,26 +99,19 @@ const TargetCursor = ({
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const strength = activeStrengthRef.current;
|
||||
const strength = activeStrengthRef.current.current;
|
||||
if (strength === 0) return;
|
||||
|
||||
const cursorX = gsap.getProperty(cursorRef.current, "x");
|
||||
const cursorY = gsap.getProperty(cursorRef.current, "y");
|
||||
|
||||
const cursorX = gsap.getProperty(cursorRef.current, "x") as number;
|
||||
const cursorY = gsap.getProperty(cursorRef.current, "y") as number;
|
||||
const corners = Array.from(cornersRef.current);
|
||||
corners.forEach((corner, i) => {
|
||||
const currentX = gsap.getProperty(corner, "x");
|
||||
const currentY = gsap.getProperty(corner, "y");
|
||||
|
||||
const targetX = targetCornerPositionsRef.current[i].x - cursorX;
|
||||
const targetY = targetCornerPositionsRef.current[i].y - cursorY;
|
||||
|
||||
const currentX = gsap.getProperty(corner, "x") as number;
|
||||
const currentY = gsap.getProperty(corner, "y") as number;
|
||||
const targetX = targetCornerPositionsRef.current![i].x - cursorX;
|
||||
const targetY = targetCornerPositionsRef.current![i].y - cursorY;
|
||||
const finalX = currentX + (targetX - currentX) * strength;
|
||||
const finalY = currentY + (targetY - currentY) * strength;
|
||||
|
||||
const duration = strength >= 0.99 ? (parallaxOn ? 0.2 : 0) : 0.05;
|
||||
|
||||
gsap.to(corner, {
|
||||
x: finalX,
|
||||
y: finalY,
|
||||
@@ -132,22 +124,20 @@ const TargetCursor = ({
|
||||
|
||||
tickerFnRef.current = tickerFn;
|
||||
|
||||
const moveHandler = (e) => moveCursor(e.clientX, e.clientY);
|
||||
const moveHandler = (e: MouseEvent) => moveCursor(e.clientX, e.clientY);
|
||||
window.addEventListener("mousemove", moveHandler);
|
||||
|
||||
const scrollHandler = () => {
|
||||
if (!activeTarget || !cursorRef.current) return;
|
||||
const mouseX = gsap.getProperty(cursorRef.current, "x");
|
||||
const mouseY = gsap.getProperty(cursorRef.current, "y");
|
||||
const mouseX = gsap.getProperty(cursorRef.current, "x") as number;
|
||||
const mouseY = gsap.getProperty(cursorRef.current, "y") as number;
|
||||
const elementUnderMouse = document.elementFromPoint(mouseX, mouseY);
|
||||
const isStillOverTarget =
|
||||
elementUnderMouse &&
|
||||
(elementUnderMouse === activeTarget ||
|
||||
elementUnderMouse.closest(targetSelector) === activeTarget);
|
||||
if (!isStillOverTarget) {
|
||||
if (currentLeaveHandler) {
|
||||
currentLeaveHandler();
|
||||
}
|
||||
currentLeaveHandler?.();
|
||||
}
|
||||
};
|
||||
window.addEventListener("scroll", scrollHandler, { passive: true });
|
||||
@@ -167,10 +157,10 @@ const TargetCursor = ({
|
||||
window.addEventListener("mousedown", mouseDownHandler);
|
||||
window.addEventListener("mouseup", mouseUpHandler);
|
||||
|
||||
const enterHandler = (e) => {
|
||||
const directTarget = e.target;
|
||||
const allTargets = [];
|
||||
let current = directTarget;
|
||||
const enterHandler = (e: MouseEvent) => {
|
||||
const directTarget = e.target as Element;
|
||||
const allTargets: Element[] = [];
|
||||
let current: Element | null = directTarget;
|
||||
while (current && current !== document.body) {
|
||||
if (current.matches(targetSelector)) {
|
||||
allTargets.push(current);
|
||||
@@ -191,15 +181,14 @@ const TargetCursor = ({
|
||||
activeTarget = target;
|
||||
const corners = Array.from(cornersRef.current);
|
||||
corners.forEach((corner) => gsap.killTweensOf(corner));
|
||||
|
||||
gsap.killTweensOf(cursorRef.current, "rotation");
|
||||
spinTl.current?.pause();
|
||||
gsap.set(cursorRef.current, { rotation: 0 });
|
||||
|
||||
const rect = target.getBoundingClientRect();
|
||||
const { borderWidth, cornerSize } = constants;
|
||||
const cursorX = gsap.getProperty(cursorRef.current, "x");
|
||||
const cursorY = gsap.getProperty(cursorRef.current, "y");
|
||||
const cursorX = gsap.getProperty(cursorRef.current, "x") as number;
|
||||
const cursorY = gsap.getProperty(cursorRef.current, "y") as number;
|
||||
|
||||
targetCornerPositionsRef.current = [
|
||||
{ x: rect.left - borderWidth, y: rect.top - borderWidth },
|
||||
@@ -215,9 +204,9 @@ const TargetCursor = ({
|
||||
];
|
||||
|
||||
isActiveRef.current = true;
|
||||
gsap.ticker.add(tickerFnRef.current);
|
||||
gsap.ticker.add(tickerFnRef.current!);
|
||||
|
||||
gsap.to(activeStrengthRef, {
|
||||
gsap.to(activeStrengthRef.current, {
|
||||
current: 1,
|
||||
duration: hoverDuration,
|
||||
ease: "power2.out",
|
||||
@@ -225,21 +214,19 @@ const TargetCursor = ({
|
||||
|
||||
corners.forEach((corner, i) => {
|
||||
gsap.to(corner, {
|
||||
x: targetCornerPositionsRef.current[i].x - cursorX,
|
||||
y: targetCornerPositionsRef.current[i].y - cursorY,
|
||||
x: targetCornerPositionsRef.current![i].x - cursorX,
|
||||
y: targetCornerPositionsRef.current![i].y - cursorY,
|
||||
duration: 0.2,
|
||||
ease: "power2.out",
|
||||
});
|
||||
});
|
||||
|
||||
const leaveHandler = () => {
|
||||
gsap.ticker.remove(tickerFnRef.current);
|
||||
|
||||
gsap.ticker.remove(tickerFnRef.current!);
|
||||
isActiveRef.current = false;
|
||||
targetCornerPositionsRef.current = null;
|
||||
gsap.set(activeStrengthRef, { current: 0, overwrite: true });
|
||||
gsap.set(activeStrengthRef.current, { current: 0, overwrite: true });
|
||||
activeTarget = null;
|
||||
|
||||
if (cornersRef.current) {
|
||||
const corners = Array.from(cornersRef.current);
|
||||
gsap.killTweensOf(corners);
|
||||
@@ -264,13 +251,12 @@ const TargetCursor = ({
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
resumeTimeout = setTimeout(() => {
|
||||
if (!activeTarget && cursorRef.current && spinTl.current) {
|
||||
const currentRotation = gsap.getProperty(
|
||||
cursorRef.current,
|
||||
"rotation",
|
||||
);
|
||||
) as number;
|
||||
const normalizedRotation = currentRotation % 360;
|
||||
spinTl.current.kill();
|
||||
spinTl.current = gsap
|
||||
@@ -291,37 +277,31 @@ const TargetCursor = ({
|
||||
}
|
||||
resumeTimeout = null;
|
||||
}, 50);
|
||||
|
||||
cleanupTarget(target);
|
||||
};
|
||||
|
||||
currentLeaveHandler = leaveHandler;
|
||||
target.addEventListener("mouseleave", leaveHandler);
|
||||
};
|
||||
|
||||
window.addEventListener("mouseover", enterHandler, { passive: true });
|
||||
window.addEventListener("mouseover", enterHandler as EventListener);
|
||||
|
||||
return () => {
|
||||
if (tickerFnRef.current) {
|
||||
gsap.ticker.remove(tickerFnRef.current);
|
||||
}
|
||||
|
||||
window.removeEventListener("mousemove", moveHandler);
|
||||
window.removeEventListener("mouseover", enterHandler);
|
||||
window.removeEventListener("mouseover", enterHandler as EventListener);
|
||||
window.removeEventListener("scroll", scrollHandler);
|
||||
window.removeEventListener("mousedown", mouseDownHandler);
|
||||
window.removeEventListener("mouseup", mouseUpHandler);
|
||||
|
||||
if (activeTarget) {
|
||||
cleanupTarget(activeTarget);
|
||||
}
|
||||
|
||||
spinTl.current?.kill();
|
||||
document.body.style.cursor = originalCursor;
|
||||
|
||||
isActiveRef.current = false;
|
||||
targetCornerPositionsRef.current = null;
|
||||
activeStrengthRef.current = 0;
|
||||
activeStrengthRef.current.current = 0;
|
||||
};
|
||||
}, [
|
||||
targetSelector,
|
||||
@@ -338,13 +318,11 @@ const TargetCursor = ({
|
||||
if (isMobile || !cursorRef.current || !spinTl.current) return;
|
||||
if (spinTl.current.isActive()) {
|
||||
spinTl.current.kill();
|
||||
spinTl.current = gsap
|
||||
.timeline({ repeat: -1 })
|
||||
.to(cursorRef.current, {
|
||||
rotation: "+=360",
|
||||
duration: spinDuration,
|
||||
ease: "none",
|
||||
});
|
||||
spinTl.current = gsap.timeline({ repeat: -1 }).to(cursorRef.current, {
|
||||
rotation: "+=360",
|
||||
duration: spinDuration,
|
||||
ease: "none",
|
||||
});
|
||||
}
|
||||
}, [spinDuration, isMobile]);
|
||||
|
||||
@@ -353,12 +331,32 @@ const TargetCursor = ({
|
||||
}
|
||||
|
||||
return (
|
||||
<div ref={cursorRef} className="target-cursor-wrapper">
|
||||
<div ref={dotRef} className="target-cursor-dot" />
|
||||
<div className="target-cursor-corner corner-tl" />
|
||||
<div className="target-cursor-corner corner-tr" />
|
||||
<div className="target-cursor-corner corner-br" />
|
||||
<div className="target-cursor-corner corner-bl" />
|
||||
<div
|
||||
ref={cursorRef}
|
||||
className="fixed top-0 left-0 w-0 h-0 pointer-events-none z-9999"
|
||||
style={{ willChange: "transform" }}
|
||||
>
|
||||
<div
|
||||
ref={dotRef}
|
||||
className="absolute top-1/2 left-1/2 w-1 h-1 bg-white rounded-full -translate-x-1/2 -translate-y-1/2"
|
||||
style={{ willChange: "transform" }}
|
||||
/>
|
||||
<div
|
||||
className="target-cursor-corner absolute top-1/2 left-1/2 w-3 h-3 border-[3px] border-white -translate-x-[150%] -translate-y-[150%] border-r-0 border-b-0"
|
||||
style={{ willChange: "transform" }}
|
||||
/>
|
||||
<div
|
||||
className="target-cursor-corner absolute top-1/2 left-1/2 w-3 h-3 border-[3px] border-white translate-x-1/2 -translate-y-[150%] border-l-0 border-b-0"
|
||||
style={{ willChange: "transform" }}
|
||||
/>
|
||||
<div
|
||||
className="target-cursor-corner absolute top-1/2 left-1/2 w-3 h-3 border-[3px] border-white translate-x-1/2 translate-y-1/2 border-l-0 border-t-0"
|
||||
style={{ willChange: "transform" }}
|
||||
/>
|
||||
<div
|
||||
className="target-cursor-corner absolute top-1/2 left-1/2 w-3 h-3 border-[3px] border-white -translate-x-[150%] translate-y-1/2 border-r-0 border-t-0"
|
||||
style={{ willChange: "transform" }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user