Contact page responsive
This commit is contained in:
+84
-54
@@ -25,8 +25,9 @@ interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
||||
}
|
||||
|
||||
interface CardSwapProps {
|
||||
width?: number | string;
|
||||
height?: number | string;
|
||||
width?: string | number;
|
||||
maxWidth?: number;
|
||||
aspectRatio?: number;
|
||||
cardDistance?: number;
|
||||
verticalDistance?: number;
|
||||
delay?: number;
|
||||
@@ -39,28 +40,47 @@ interface CardSwapProps {
|
||||
|
||||
// --- Composant Card ---
|
||||
export const Card = forwardRef<HTMLDivElement, CardProps>(
|
||||
({ customClass, className, ...rest }, ref) => (
|
||||
({ customClass, className, onClick, style, ...rest }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
onClick={onClick}
|
||||
{...rest}
|
||||
className={`absolute top-1/2 left-1/2 transform-3d will-change-transform pointer-events-auto! ${customClass ?? ""} ${className ?? ""}`.trim()}
|
||||
className={`absolute top-1/2 left-1/2 w-[80%] md:w-[85%] h-full transform-3d will-change-transform ${customClass ?? ""} ${className ?? ""}`.trim()}
|
||||
style={{ ...style, pointerEvents: "auto", cursor: "pointer" }}
|
||||
/>
|
||||
),
|
||||
);
|
||||
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,
|
||||
});
|
||||
containerWidth: number,
|
||||
): Slot => {
|
||||
let factorX = 0.6;
|
||||
let factorY = 0.5;
|
||||
|
||||
if (containerWidth < 768) {
|
||||
factorX = 0.25;
|
||||
factorY = 0.25;
|
||||
} else if (containerWidth < 1300) {
|
||||
const progress = (containerWidth - 768) / (1300 - 768);
|
||||
factorX = 0.3 + progress * 0.3;
|
||||
factorY = 0.4;
|
||||
}
|
||||
|
||||
const totalWidth = (total - 1) * distX * factorX;
|
||||
const centeringOffset = totalWidth / 2;
|
||||
|
||||
return {
|
||||
x: i * distX * factorX - centeringOffset,
|
||||
y: -i * distY * factorY,
|
||||
z: -i * distX * 2 * factorX,
|
||||
zIndex: total - i,
|
||||
};
|
||||
};
|
||||
|
||||
const placeNow = (el: HTMLDivElement | null, slot: Slot, skew: number) => {
|
||||
if (!el) return;
|
||||
@@ -69,7 +89,7 @@ const placeNow = (el: HTMLDivElement | null, slot: Slot, skew: number) => {
|
||||
y: slot.y,
|
||||
z: slot.z,
|
||||
xPercent: -50,
|
||||
yPercent: -50,
|
||||
yPercent: -40,
|
||||
skewY: skew,
|
||||
transformOrigin: "center center",
|
||||
zIndex: slot.zIndex,
|
||||
@@ -77,10 +97,10 @@ const placeNow = (el: HTMLDivElement | null, slot: Slot, skew: number) => {
|
||||
});
|
||||
};
|
||||
|
||||
// --- Composant Principal ---
|
||||
const CardSwap: React.FC<CardSwapProps> = ({
|
||||
width = 500,
|
||||
height = 400,
|
||||
width = "100%",
|
||||
maxWidth = 1100,
|
||||
aspectRatio = 2.2,
|
||||
cardDistance = 60,
|
||||
verticalDistance = 70,
|
||||
delay = 5000,
|
||||
@@ -90,6 +110,20 @@ const CardSwap: React.FC<CardSwapProps> = ({
|
||||
easing = "elastic",
|
||||
children,
|
||||
}) => {
|
||||
const container = useRef<HTMLDivElement>(null);
|
||||
const childArr = useMemo(() => Children.toArray(children), [children]);
|
||||
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 [currentWidth, setCurrentWidth] = useState(0);
|
||||
|
||||
const config = useMemo(
|
||||
() =>
|
||||
easing === "elastic"
|
||||
@@ -112,58 +146,56 @@ const CardSwap: React.FC<CardSwapProps> = ({
|
||||
[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 updatePositions = () => {
|
||||
const w = container.current?.clientWidth || window.innerWidth;
|
||||
|
||||
refs.forEach((r, i) => {
|
||||
placeNow(
|
||||
r.current,
|
||||
makeSlot(i, cardDistance, verticalDistance, total, w),
|
||||
skewAmount,
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
updatePositions();
|
||||
|
||||
const handleResize = () => {
|
||||
if (container.current) {
|
||||
setCurrentWidth(container.current.clientWidth);
|
||||
updatePositions();
|
||||
}
|
||||
};
|
||||
window.addEventListener("resize", handleResize);
|
||||
|
||||
const swap = () => {
|
||||
if (order.current.length < 2) return;
|
||||
|
||||
const [front, ...rest] = order.current;
|
||||
const elFront = refs[front].current;
|
||||
if (!elFront) return;
|
||||
|
||||
const w = container.current?.clientWidth || window.innerWidth;
|
||||
|
||||
const tl = gsap.timeline();
|
||||
tlRef.current = tl;
|
||||
|
||||
// Animation de descente
|
||||
tl.to(elFront, {
|
||||
y: "+=500",
|
||||
opacity: 0,
|
||||
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);
|
||||
const slot = makeSlot(i, cardDistance, verticalDistance, total, w);
|
||||
|
||||
tl.set(el, { zIndex: slot.zIndex }, "promote");
|
||||
tl.to(
|
||||
@@ -179,12 +211,12 @@ const CardSwap: React.FC<CardSwapProps> = ({
|
||||
);
|
||||
});
|
||||
|
||||
// Retour de la carte de devant vers le fond
|
||||
const backSlot = makeSlot(
|
||||
total - 1,
|
||||
cardDistance,
|
||||
verticalDistance,
|
||||
total,
|
||||
w,
|
||||
);
|
||||
tl.addLabel("return", `promote+=${config.durMove * config.returnDelay}`);
|
||||
|
||||
@@ -195,6 +227,7 @@ const CardSwap: React.FC<CardSwapProps> = ({
|
||||
x: backSlot.x,
|
||||
y: backSlot.y,
|
||||
z: backSlot.z,
|
||||
opacity: 1,
|
||||
duration: config.durReturn,
|
||||
ease: config.ease,
|
||||
},
|
||||
@@ -208,7 +241,6 @@ const CardSwap: React.FC<CardSwapProps> = ({
|
||||
|
||||
intervalRef.current = window.setInterval(swap, delay);
|
||||
|
||||
// Gestion du Hover
|
||||
const node = container.current;
|
||||
if (pauseOnHover && node) {
|
||||
const pause = () => {
|
||||
@@ -221,7 +253,6 @@ const CardSwap: React.FC<CardSwapProps> = ({
|
||||
};
|
||||
node.addEventListener("mouseenter", pause);
|
||||
node.addEventListener("mouseleave", resume);
|
||||
|
||||
return () => {
|
||||
node.removeEventListener("mouseenter", pause);
|
||||
node.removeEventListener("mouseleave", resume);
|
||||
@@ -230,6 +261,7 @@ const CardSwap: React.FC<CardSwapProps> = ({
|
||||
}
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("resize", handleResize);
|
||||
if (intervalRef.current) clearInterval(intervalRef.current);
|
||||
};
|
||||
}, [
|
||||
@@ -242,19 +274,12 @@ const CardSwap: React.FC<CardSwapProps> = ({
|
||||
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);
|
||||
@@ -265,8 +290,13 @@ const CardSwap: React.FC<CardSwapProps> = ({
|
||||
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 }}
|
||||
className="relative mx-auto perspective-[3000px] overflow-visible py-20 px-4 md:px-12 flex justify-center items-center"
|
||||
style={{
|
||||
width: width,
|
||||
maxWidth: `${maxWidth}px`,
|
||||
aspectRatio: `${aspectRatio}`,
|
||||
height: typeof width === "number" ? "auto" : undefined,
|
||||
}}
|
||||
>
|
||||
{rendered}
|
||||
</div>
|
||||
|
||||
@@ -53,7 +53,7 @@ function FlowingMenu({
|
||||
))}
|
||||
<div
|
||||
style={{
|
||||
height: activeIdx !== null ? "60vh" : "0px",
|
||||
height: "0px",
|
||||
transition: "height 0.5s ease",
|
||||
width: "100%",
|
||||
pointerEvents: "none",
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
.lanyard-root-container {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
z-index: 99999;
|
||||
pointer-events: none;
|
||||
background: transparent;
|
||||
|
||||
/* Animation d'entrée douce */
|
||||
animation: lanyardFadeIn 0.8s ease-out forwards;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
@keyframes lanyardFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.lanyard-root-container canvas {
|
||||
pointer-events: auto !important;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
+139
-59
@@ -1,13 +1,22 @@
|
||||
/* eslint-disable react/no-unknown-property */
|
||||
"use client";
|
||||
import {
|
||||
import React, {
|
||||
useRef,
|
||||
useState,
|
||||
useMemo,
|
||||
Suspense,
|
||||
useEffect,
|
||||
useSyncExternalStore,
|
||||
} from "react";
|
||||
import { ThreeElement } from "@react-three/fiber";
|
||||
import { createPortal } from "react-dom";
|
||||
import { Canvas, extend, useFrame, useThree } from "@react-three/fiber";
|
||||
import {
|
||||
Canvas,
|
||||
extend,
|
||||
useFrame,
|
||||
useThree,
|
||||
ThreeEvent,
|
||||
} from "@react-three/fiber";
|
||||
import {
|
||||
useGLTF,
|
||||
useTexture,
|
||||
@@ -21,15 +30,20 @@ import {
|
||||
RigidBody,
|
||||
useRopeJoint,
|
||||
useSphericalJoint,
|
||||
RigidBodyProps,
|
||||
} from "@react-three/rapier";
|
||||
import { MeshLineGeometry, MeshLineMaterial } from "meshline";
|
||||
import * as THREE from "three";
|
||||
|
||||
import "./Lanyard.css";
|
||||
|
||||
extend({ MeshLineGeometry, MeshLineMaterial });
|
||||
|
||||
// Détection propre du client (Standard React 19) pour éviter les erreurs ESLint
|
||||
declare module "@react-three/fiber" {
|
||||
interface ThreeElements {
|
||||
meshLineGeometry: ThreeElement<typeof MeshLineGeometry>;
|
||||
meshLineMaterial: ThreeElement<typeof MeshLineMaterial>;
|
||||
}
|
||||
}
|
||||
|
||||
const subscribe = () => () => {};
|
||||
function useIsClient() {
|
||||
return useSyncExternalStore(
|
||||
@@ -39,22 +53,52 @@ function useIsClient() {
|
||||
);
|
||||
}
|
||||
|
||||
export default function Lanyard({ show, gravity = [0, -20, 0], fov = 20 }) {
|
||||
interface LanyardProps {
|
||||
show: boolean;
|
||||
gravity?: [number, number, number];
|
||||
fov?: number;
|
||||
transparent?: boolean;
|
||||
}
|
||||
|
||||
export default function Lanyard({
|
||||
show,
|
||||
gravity = [0, -20, 0],
|
||||
fov = 20,
|
||||
transparent = true,
|
||||
}: LanyardProps) {
|
||||
const isClient = useIsClient();
|
||||
const [isMobile, setIsMobile] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window !== "undefined") {
|
||||
setIsMobile(window.innerWidth < 768);
|
||||
const handleResize = () => setIsMobile(window.innerWidth < 768);
|
||||
window.addEventListener("resize", handleResize);
|
||||
return () => window.removeEventListener("resize", handleResize);
|
||||
}
|
||||
}, []);
|
||||
|
||||
if (!show || !isClient) return null;
|
||||
|
||||
return createPortal(
|
||||
<div className="lanyard-root-container">
|
||||
<div className="fixed inset-0 z-99999 pointer-events-none bg-transparent transition-opacity duration-1000 ease-out opacity-100">
|
||||
<Canvas
|
||||
camera={{ position: [0, 0, 20], fov }}
|
||||
gl={{ alpha: true, antialias: true }}
|
||||
gl={{ alpha: transparent, antialias: true }}
|
||||
dpr={[1, isMobile ? 1.5 : 2]}
|
||||
onCreated={({ gl }) => gl.setClearColor(new THREE.Color(0x000000), 0)}
|
||||
className="block w-full h-full pointer-events-auto"
|
||||
>
|
||||
<Suspense fallback={null}>
|
||||
<Physics gravity={gravity} interpolate={true}>
|
||||
<Band />
|
||||
<Physics
|
||||
gravity={gravity}
|
||||
interpolate={true}
|
||||
timeStep={isMobile ? 1 / 30 : 1 / 60}
|
||||
>
|
||||
<Band isMobile={isMobile} />
|
||||
</Physics>
|
||||
</Suspense>
|
||||
|
||||
<Environment blur={0.75}>
|
||||
<Lightformer
|
||||
intensity={10}
|
||||
@@ -70,64 +114,78 @@ export default function Lanyard({ show, gravity = [0, -20, 0], fov = 20 }) {
|
||||
);
|
||||
}
|
||||
|
||||
function Band() {
|
||||
interface BandProps {
|
||||
isMobile: boolean;
|
||||
}
|
||||
|
||||
function Band({ isMobile }: BandProps) {
|
||||
const { size } = useThree();
|
||||
const band = useRef(),
|
||||
fixed = useRef(),
|
||||
j1 = useRef(),
|
||||
j2 = useRef(),
|
||||
j3 = useRef(),
|
||||
card = useRef();
|
||||
const vec = new THREE.Vector3(),
|
||||
dir = new THREE.Vector3();
|
||||
const band = useRef<any>(null);
|
||||
const fixed = useRef<any>(null);
|
||||
const j1 = useRef<any>(null);
|
||||
const j2 = useRef<any>(null);
|
||||
const j3 = useRef<any>(null);
|
||||
const card = useRef<any>(null);
|
||||
|
||||
const { nodes, materials } = useGLTF("/3d/card.glb");
|
||||
const vec = new THREE.Vector3();
|
||||
const dir = new THREE.Vector3();
|
||||
const ang = new THREE.Vector3();
|
||||
const rot = new THREE.Vector3();
|
||||
|
||||
const texture = useTexture("/3d/lanyard.png", (t) => {
|
||||
t.wrapS = t.wrapT = THREE.RepeatWrapping;
|
||||
t.repeat.set(-4, 1);
|
||||
t.anisotropy = 16;
|
||||
});
|
||||
const { nodes, materials } = useGLTF("/3d/card.glb") as any;
|
||||
const texture = useTexture("/3d/lanyard.png");
|
||||
const badgeTexture = useTexture("/3d/badge_texture.png");
|
||||
|
||||
const cardTexture = useTexture("/3d/badge_texture.png", (t) => {
|
||||
t.flipY = false;
|
||||
t.anisotropy = 16;
|
||||
});
|
||||
|
||||
const curve = useMemo(
|
||||
const [curve] = useState(
|
||||
() =>
|
||||
new THREE.CatmullRomCurve3(
|
||||
new Array(4).fill(null).map(() => new THREE.Vector3()),
|
||||
),
|
||||
[],
|
||||
);
|
||||
const [dragged, drag] = useState(false);
|
||||
const [dragged, drag] = useState<THREE.Vector3 | false>(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (texture) {
|
||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
|
||||
texture.repeat.set(-4, 1);
|
||||
texture.anisotropy = 16;
|
||||
}
|
||||
if (badgeTexture) {
|
||||
badgeTexture.flipY = false;
|
||||
badgeTexture.anisotropy = 16;
|
||||
}
|
||||
}, [texture, badgeTexture]);
|
||||
|
||||
// JOINTS PHYSIQUES
|
||||
useRopeJoint(fixed, j1, [[0, 0, 0], [0, 0, 0], 1.2]);
|
||||
useRopeJoint(j1, j2, [[0, 0, 0], [0, 0, 0], 1.2]);
|
||||
useRopeJoint(j2, j3, [[0, 0, 0], [0, 0, 0], 1.2]);
|
||||
|
||||
// CONNEXION PHYSIQUE : L'ancre j3 est soudée au haut du collider de la carte
|
||||
useSphericalJoint(j3, card, [
|
||||
[0, 0, 0],
|
||||
[0, 1.1, 0],
|
||||
]);
|
||||
|
||||
useFrame((state, delta) => {
|
||||
if (dragged) {
|
||||
if (dragged && card.current) {
|
||||
vec.set(state.pointer.x, state.pointer.y, 0.5).unproject(state.camera);
|
||||
dir.copy(vec).sub(state.camera.position).normalize();
|
||||
vec.add(dir.multiplyScalar(state.camera.position.length()));
|
||||
|
||||
[card, j1, j2, j3, fixed].forEach((ref) => ref.current?.wakeUp());
|
||||
card.current?.setNextKinematicTranslation({
|
||||
|
||||
card.current.setNextKinematicTranslation({
|
||||
x: vec.x - dragged.x,
|
||||
y: vec.y - dragged.y,
|
||||
z: vec.z - dragged.z,
|
||||
});
|
||||
}
|
||||
|
||||
if (fixed.current) {
|
||||
if (
|
||||
fixed.current &&
|
||||
card.current &&
|
||||
j1.current &&
|
||||
j2.current &&
|
||||
band.current
|
||||
) {
|
||||
[j1, j2].forEach((ref) => {
|
||||
if (!ref.current.lerped)
|
||||
ref.current.lerped = new THREE.Vector3().copy(
|
||||
@@ -141,63 +199,81 @@ function Band() {
|
||||
curve.points[1].copy(j2.current.lerped);
|
||||
curve.points[2].copy(j1.current.lerped);
|
||||
curve.points[3].copy(fixed.current.translation());
|
||||
band.current.geometry.setPoints(curve.getPoints(32));
|
||||
band.current.geometry.setPoints(curve.getPoints(isMobile ? 16 : 32));
|
||||
|
||||
ang.copy(card.current.angvel());
|
||||
rot.copy(card.current.rotation());
|
||||
card.current.setAngvel({ x: ang.x, y: ang.y - rot.y * 0.25, z: ang.z });
|
||||
}
|
||||
});
|
||||
|
||||
const physicsProps = {
|
||||
type: "dynamic",
|
||||
linearDamping: 4,
|
||||
linearDamping: 6,
|
||||
angularDamping: 4,
|
||||
friction: 0.5,
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<group position={[4, 5, 0]}>
|
||||
<group position={[1, 5, 0]}>
|
||||
<RigidBody ref={fixed} type="fixed" />
|
||||
<RigidBody position={[0, 2, 0]} ref={j1} {...physicsProps}>
|
||||
<RigidBody
|
||||
position={[0, 2, 0]}
|
||||
ref={j1}
|
||||
type="dynamic"
|
||||
{...physicsProps}
|
||||
>
|
||||
<BallCollider args={[0.1]} />
|
||||
</RigidBody>
|
||||
<RigidBody position={[0, 2, 0]} ref={j2} {...physicsProps}>
|
||||
<RigidBody
|
||||
position={[0, 2, 0]}
|
||||
ref={j2}
|
||||
type="dynamic"
|
||||
{...physicsProps}
|
||||
>
|
||||
<BallCollider args={[0.1]} />
|
||||
</RigidBody>
|
||||
<RigidBody position={[0, 2, 0]} ref={j3} {...physicsProps}>
|
||||
<RigidBody
|
||||
position={[0, 2, 0]}
|
||||
ref={j3}
|
||||
type="dynamic"
|
||||
{...physicsProps}
|
||||
>
|
||||
<BallCollider args={[0.1]} />
|
||||
</RigidBody>
|
||||
|
||||
<RigidBody
|
||||
ref={card}
|
||||
{...physicsProps}
|
||||
type={dragged ? "kinematicPosition" : "dynamic"}
|
||||
position={[0, 2, 0]}
|
||||
{...physicsProps}
|
||||
>
|
||||
<CuboidCollider args={[0.8, 1.125, 0.01]} />
|
||||
<group
|
||||
scale={2.25}
|
||||
position={[0, -1.2, 0]}
|
||||
onPointerDown={(e) => {
|
||||
e.target.setPointerCapture(e.pointerId);
|
||||
onPointerDown={(e: ThreeEvent<PointerEvent>) => {
|
||||
(e.target as HTMLElement).setPointerCapture(e.pointerId);
|
||||
drag(
|
||||
new THREE.Vector3()
|
||||
.copy(e.point)
|
||||
.sub(vec.copy(card.current.translation())),
|
||||
);
|
||||
}}
|
||||
onPointerUp={(e) => (
|
||||
e.target.releasePointerCapture(e.pointerId),
|
||||
drag(false)
|
||||
)}
|
||||
onPointerUp={(e: ThreeEvent<PointerEvent>) => {
|
||||
(e.target as HTMLElement).releasePointerCapture(e.pointerId);
|
||||
drag(false);
|
||||
}}
|
||||
>
|
||||
{/* renderOrder={2} : La carte passe DEVANT la lanière */}
|
||||
<mesh
|
||||
geometry={nodes.card.geometry}
|
||||
rotation={[Math.PI / 2, 0, 0]}
|
||||
renderOrder={2}
|
||||
>
|
||||
<meshPhysicalMaterial
|
||||
map={cardTexture}
|
||||
clearcoat={1}
|
||||
map={badgeTexture}
|
||||
clearcoat={isMobile ? 0 : 1}
|
||||
clearcoatRoughness={0.15}
|
||||
roughness={0.3}
|
||||
metalness={0.2}
|
||||
/>
|
||||
@@ -213,14 +289,18 @@ function Band() {
|
||||
</RigidBody>
|
||||
</group>
|
||||
|
||||
{/* renderOrder={1} : Dessiné en premier (derrière) */}
|
||||
<mesh ref={band} renderOrder={1}>
|
||||
<meshLineGeometry />
|
||||
<meshLineMaterial
|
||||
transparent
|
||||
args={[
|
||||
{
|
||||
resolution: new THREE.Vector2(size.width, size.height),
|
||||
} as any,
|
||||
]}
|
||||
transparent={true}
|
||||
depthTest={false}
|
||||
resolution={[size.width, size.height]}
|
||||
useMap
|
||||
useMap={1}
|
||||
map={texture}
|
||||
repeat={[-4, 1]}
|
||||
lineWidth={1.2}
|
||||
|
||||
@@ -1,183 +0,0 @@
|
||||
.logoloop {
|
||||
position: relative;
|
||||
|
||||
--logoloop-gap: 32px;
|
||||
--logoloop-logoHeight: 28px;
|
||||
--logoloop-fadeColorAuto: #ffffff;
|
||||
}
|
||||
|
||||
.logoloop--vertical {
|
||||
height: 100%;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.logoloop--scale-hover {
|
||||
padding-top: calc(var(--logoloop-logoHeight) * 0.1);
|
||||
padding-bottom: calc(var(--logoloop-logoHeight) * 0.1);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.logoloop {
|
||||
--logoloop-fadeColorAuto: #0b0b0b;
|
||||
}
|
||||
}
|
||||
|
||||
.logoloop__track {
|
||||
display: flex;
|
||||
width: max-content;
|
||||
will-change: transform;
|
||||
user-select: none;
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.logoloop--vertical .logoloop__track {
|
||||
flex-direction: column;
|
||||
height: max-content;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.logoloop__list {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.logoloop--vertical .logoloop__list {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.logoloop__item {
|
||||
flex: 0 0 auto;
|
||||
margin-right: var(--logoloop-gap);
|
||||
font-size: var(--logoloop-logoHeight);
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.logoloop--vertical .logoloop__item {
|
||||
margin-right: 0;
|
||||
margin-bottom: var(--logoloop-gap);
|
||||
}
|
||||
|
||||
.logoloop__item:last-child {
|
||||
margin-right: var(--logoloop-gap);
|
||||
}
|
||||
|
||||
.logoloop--vertical .logoloop__item:last-child {
|
||||
margin-right: 0;
|
||||
margin-bottom: var(--logoloop-gap);
|
||||
}
|
||||
|
||||
.logoloop__node {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.logoloop__item img {
|
||||
height: var(--logoloop-logoHeight);
|
||||
width: auto;
|
||||
display: block;
|
||||
object-fit: contain;
|
||||
image-rendering: -webkit-optimize-contrast;
|
||||
-webkit-user-drag: none;
|
||||
pointer-events: none;
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.logoloop--scale-hover .logoloop__item {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.logoloop--scale-hover .logoloop__item:hover img,
|
||||
.logoloop--scale-hover .logoloop__item:hover .logoloop__node {
|
||||
transform: scale(1.2);
|
||||
transform-origin: center center;
|
||||
}
|
||||
|
||||
.logoloop--scale-hover .logoloop__node {
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.logoloop__link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.logoloop__link:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.logoloop__link:focus-visible {
|
||||
outline: 2px solid currentColor;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.logoloop--fade::before,
|
||||
.logoloop--fade::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: clamp(24px, 8%, 120px);
|
||||
pointer-events: none;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.logoloop--fade::before {
|
||||
left: 0;
|
||||
background: linear-gradient(
|
||||
to right,
|
||||
var(--logoloop-fadeColor, var(--logoloop-fadeColorAuto)) 0%,
|
||||
rgba(0, 0, 0, 0) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.logoloop--fade::after {
|
||||
right: 0;
|
||||
background: linear-gradient(
|
||||
to left,
|
||||
var(--logoloop-fadeColor, var(--logoloop-fadeColorAuto)) 0%,
|
||||
rgba(0, 0, 0, 0) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.logoloop--vertical.logoloop--fade::before,
|
||||
.logoloop--vertical.logoloop--fade::after {
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: clamp(24px, 8%, 120px);
|
||||
}
|
||||
|
||||
.logoloop--vertical.logoloop--fade::before {
|
||||
top: 0;
|
||||
bottom: auto;
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
var(--logoloop-fadeColor, var(--logoloop-fadeColorAuto)) 0%,
|
||||
rgba(0, 0, 0, 0) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.logoloop--vertical.logoloop--fade::after {
|
||||
bottom: 0;
|
||||
top: auto;
|
||||
background: linear-gradient(
|
||||
to top,
|
||||
var(--logoloop-fadeColor, var(--logoloop-fadeColorAuto)) 0%,
|
||||
rgba(0, 0, 0, 0) 100%
|
||||
);
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.logoloop__track {
|
||||
transform: translate3d(0, 0, 0) !important;
|
||||
}
|
||||
|
||||
.logoloop__item img,
|
||||
.logoloop__node {
|
||||
transition: none !important;
|
||||
}
|
||||
}
|
||||
+242
-78
@@ -1,12 +1,64 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, memo } from "react";
|
||||
import "./LogoLoop.css";
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
|
||||
const ANIMATION_CONFIG = { SMOOTH_TAU: 0.25, MIN_COPIES: 2, COPY_HEADROOM: 2 };
|
||||
export type LogoItem =
|
||||
| {
|
||||
node: React.ReactNode;
|
||||
href?: string;
|
||||
title?: string;
|
||||
ariaLabel?: string;
|
||||
}
|
||||
| {
|
||||
src: string;
|
||||
alt?: string;
|
||||
href?: string;
|
||||
title?: string;
|
||||
srcSet?: string;
|
||||
sizes?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
};
|
||||
|
||||
const toCssLength = (value) =>
|
||||
export interface LogoLoopProps {
|
||||
logos: LogoItem[];
|
||||
speed?: number;
|
||||
direction?: "left" | "right" | "up" | "down";
|
||||
width?: number | string;
|
||||
logoHeight?: number;
|
||||
gap?: number;
|
||||
pauseOnHover?: boolean;
|
||||
hoverSpeed?: number;
|
||||
fadeOut?: boolean;
|
||||
fadeOutColor?: string;
|
||||
scaleOnHover?: boolean;
|
||||
renderItem?: (item: LogoItem, key: React.Key) => React.ReactNode;
|
||||
ariaLabel?: string;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
|
||||
const ANIMATION_CONFIG = {
|
||||
SMOOTH_TAU: 0.25,
|
||||
MIN_COPIES: 2,
|
||||
COPY_HEADROOM: 2,
|
||||
} as const;
|
||||
|
||||
const toCssLength = (value?: number | string): string | undefined =>
|
||||
typeof value === "number" ? `${value}px` : (value ?? undefined);
|
||||
|
||||
const useResizeObserver = (callback, elements, dependencies) => {
|
||||
const cx = (...parts: Array<string | false | null | undefined>) =>
|
||||
parts.filter(Boolean).join(" ");
|
||||
|
||||
const useResizeObserver = (
|
||||
callback: () => void,
|
||||
elements: Array<React.RefObject<Element | null>>,
|
||||
dependencies: React.DependencyList,
|
||||
) => {
|
||||
useEffect(() => {
|
||||
if (!window.ResizeObserver) {
|
||||
const handleResize = () => callback();
|
||||
@@ -14,33 +66,45 @@ const useResizeObserver = (callback, elements, dependencies) => {
|
||||
callback();
|
||||
return () => window.removeEventListener("resize", handleResize);
|
||||
}
|
||||
|
||||
const observers = elements.map((ref) => {
|
||||
if (!ref.current) return null;
|
||||
const observer = new ResizeObserver(callback);
|
||||
observer.observe(ref.current);
|
||||
return observer;
|
||||
});
|
||||
|
||||
callback();
|
||||
|
||||
return () => {
|
||||
observers.forEach((observer) => observer?.disconnect());
|
||||
};
|
||||
}, [callback, elements, dependencies]);
|
||||
}, dependencies);
|
||||
};
|
||||
|
||||
const useImageLoader = (seqRef, onLoad, dependencies) => {
|
||||
const useImageLoader = (
|
||||
seqRef: React.RefObject<HTMLUListElement | null>,
|
||||
onLoad: () => void,
|
||||
dependencies: React.DependencyList,
|
||||
) => {
|
||||
useEffect(() => {
|
||||
const images = seqRef.current?.querySelectorAll("img") ?? [];
|
||||
|
||||
if (images.length === 0) {
|
||||
onLoad();
|
||||
return;
|
||||
}
|
||||
|
||||
let remainingImages = images.length;
|
||||
const handleImageLoad = () => {
|
||||
remainingImages -= 1;
|
||||
if (remainingImages === 0) onLoad();
|
||||
if (remainingImages === 0) {
|
||||
onLoad();
|
||||
}
|
||||
};
|
||||
|
||||
images.forEach((img) => {
|
||||
const htmlImg = img;
|
||||
const htmlImg = img as HTMLImageElement;
|
||||
if (htmlImg.complete) {
|
||||
handleImageLoad();
|
||||
} else {
|
||||
@@ -48,26 +112,27 @@ const useImageLoader = (seqRef, onLoad, dependencies) => {
|
||||
htmlImg.addEventListener("error", handleImageLoad, { once: true });
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
images.forEach((img) => {
|
||||
img.removeEventListener("load", handleImageLoad);
|
||||
img.removeEventListener("error", handleImageLoad);
|
||||
});
|
||||
};
|
||||
}, [onLoad, seqRef, dependencies]);
|
||||
}, dependencies);
|
||||
};
|
||||
|
||||
const useAnimationLoop = (
|
||||
trackRef,
|
||||
targetVelocity,
|
||||
seqWidth,
|
||||
seqHeight,
|
||||
isHovered,
|
||||
hoverSpeed,
|
||||
isVertical,
|
||||
trackRef: React.RefObject<HTMLDivElement | null>,
|
||||
targetVelocity: number,
|
||||
seqWidth: number,
|
||||
seqHeight: number,
|
||||
isHovered: boolean,
|
||||
hoverSpeed: number | undefined,
|
||||
isVertical: boolean,
|
||||
) => {
|
||||
const rafRef = useRef(null);
|
||||
const lastTimestampRef = useRef(null);
|
||||
const rafRef = useRef<number | null>(null);
|
||||
const lastTimestampRef = useRef<number | null>(null);
|
||||
const offsetRef = useRef(0);
|
||||
const velocityRef = useRef(0);
|
||||
|
||||
@@ -75,6 +140,11 @@ const useAnimationLoop = (
|
||||
const track = trackRef.current;
|
||||
if (!track) return;
|
||||
|
||||
const prefersReduced =
|
||||
typeof window !== "undefined" &&
|
||||
window.matchMedia &&
|
||||
window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||
|
||||
const seqSize = isVertical ? seqHeight : seqWidth;
|
||||
|
||||
if (seqSize > 0) {
|
||||
@@ -85,7 +155,16 @@ const useAnimationLoop = (
|
||||
track.style.transform = transformValue;
|
||||
}
|
||||
|
||||
const animate = (timestamp) => {
|
||||
if (prefersReduced) {
|
||||
track.style.transform = isVertical
|
||||
? "translate3d(0, 0, 0)"
|
||||
: "translate3d(0, 0, 0)";
|
||||
return () => {
|
||||
lastTimestampRef.current = null;
|
||||
};
|
||||
}
|
||||
|
||||
const animate = (timestamp: number) => {
|
||||
if (lastTimestampRef.current === null) {
|
||||
lastTimestampRef.current = timestamp;
|
||||
}
|
||||
@@ -124,18 +203,10 @@ const useAnimationLoop = (
|
||||
}
|
||||
lastTimestampRef.current = null;
|
||||
};
|
||||
}, [
|
||||
targetVelocity,
|
||||
seqWidth,
|
||||
seqHeight,
|
||||
isHovered,
|
||||
hoverSpeed,
|
||||
isVertical,
|
||||
trackRef,
|
||||
]);
|
||||
}, [targetVelocity, seqWidth, seqHeight, isHovered, hoverSpeed, isVertical]);
|
||||
};
|
||||
|
||||
export const LogoLoop = memo(
|
||||
export const LogoLoop = React.memo<LogoLoopProps>(
|
||||
({
|
||||
logos,
|
||||
speed = 120,
|
||||
@@ -153,14 +224,16 @@ export const LogoLoop = memo(
|
||||
className,
|
||||
style,
|
||||
}) => {
|
||||
const containerRef = useRef(null);
|
||||
const trackRef = useRef(null);
|
||||
const seqRef = useRef(null);
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const trackRef = useRef<HTMLDivElement>(null);
|
||||
const seqRef = useRef<HTMLUListElement>(null);
|
||||
|
||||
const [seqWidth, setSeqWidth] = useState(0);
|
||||
const [seqHeight, setSeqHeight] = useState(0);
|
||||
const [copyCount, setCopyCount] = useState(ANIMATION_CONFIG.MIN_COPIES);
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
const [seqWidth, setSeqWidth] = useState<number>(0);
|
||||
const [seqHeight, setSeqHeight] = useState<number>(0);
|
||||
const [copyCount, setCopyCount] = useState<number>(
|
||||
ANIMATION_CONFIG.MIN_COPIES,
|
||||
);
|
||||
const [isHovered, setIsHovered] = useState<boolean>(false);
|
||||
|
||||
const effectiveHoverSpeed = useMemo(() => {
|
||||
if (hoverSpeed !== undefined) return hoverSpeed;
|
||||
@@ -173,7 +246,7 @@ export const LogoLoop = memo(
|
||||
|
||||
const targetVelocity = useMemo(() => {
|
||||
const magnitude = Math.abs(speed);
|
||||
let directionMultiplier;
|
||||
let directionMultiplier: number;
|
||||
if (isVertical) {
|
||||
directionMultiplier = direction === "up" ? 1 : -1;
|
||||
} else {
|
||||
@@ -240,26 +313,30 @@ export const LogoLoop = memo(
|
||||
);
|
||||
|
||||
const cssVariables = useMemo(
|
||||
() => ({
|
||||
"--logoloop-gap": `${gap}px`,
|
||||
"--logoloop-logoHeight": `${logoHeight}px`,
|
||||
...(fadeOutColor && { "--logoloop-fadeColor": fadeOutColor }),
|
||||
}),
|
||||
() =>
|
||||
({
|
||||
"--logoloop-gap": `${gap}px`,
|
||||
"--logoloop-logoHeight": `${logoHeight}px`,
|
||||
...(fadeOutColor && { "--logoloop-fadeColor": fadeOutColor }),
|
||||
}) as React.CSSProperties,
|
||||
[gap, logoHeight, fadeOutColor],
|
||||
);
|
||||
|
||||
const rootClassName = useMemo(
|
||||
const rootClasses = useMemo(
|
||||
() =>
|
||||
[
|
||||
"logoloop",
|
||||
isVertical ? "logoloop--vertical" : "logoloop--horizontal",
|
||||
fadeOut && "logoloop--fade",
|
||||
scaleOnHover && "logoloop--scale-hover",
|
||||
cx(
|
||||
"relative group",
|
||||
isVertical
|
||||
? "overflow-hidden h-full inline-block"
|
||||
: "overflow-x-hidden",
|
||||
"[--logoloop-gap:32px]",
|
||||
"[--logoloop-logoHeight:28px]",
|
||||
"[--logoloop-fadeColorAuto:#ffffff]",
|
||||
"dark:[--logoloop-fadeColorAuto:#0b0b0b]",
|
||||
scaleOnHover && "py-[calc(var(--logoloop-logoHeight)*0.1)]",
|
||||
className,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" "),
|
||||
[isVertical, fadeOut, scaleOnHover, className],
|
||||
),
|
||||
[isVertical, scaleOnHover, className],
|
||||
);
|
||||
|
||||
const handleMouseEnter = useCallback(() => {
|
||||
@@ -270,43 +347,73 @@ export const LogoLoop = memo(
|
||||
}, [effectiveHoverSpeed]);
|
||||
|
||||
const renderLogoItem = useCallback(
|
||||
(item, key) => {
|
||||
(item: LogoItem, key: React.Key) => {
|
||||
if (renderItem) {
|
||||
return (
|
||||
<li className="logoloop__item" key={key} role="listitem">
|
||||
<li
|
||||
className={cx(
|
||||
"flex-none text-(length:--logoloop-logoHeight) leading-none",
|
||||
isVertical ? "mb-(--logoloop-gap)" : "mr-(--logoloop-gap)",
|
||||
scaleOnHover && "overflow-visible group/item",
|
||||
)}
|
||||
key={key}
|
||||
role="listitem"
|
||||
>
|
||||
{renderItem(item, key)}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
const isNodeItem = "node" in item;
|
||||
|
||||
const content = isNodeItem ? (
|
||||
<span
|
||||
className="logoloop__node"
|
||||
aria-hidden={!!item.href && !item.ariaLabel}
|
||||
className={cx(
|
||||
"inline-flex items-center",
|
||||
"motion-reduce:transition-none",
|
||||
scaleOnHover &&
|
||||
"transition-transform duration-300 ease-in-out group-hover/item:scale-120",
|
||||
)}
|
||||
aria-hidden={!!(item as any).href && !(item as any).ariaLabel}
|
||||
>
|
||||
{item.node}
|
||||
{(item as any).node}
|
||||
</span>
|
||||
) : (
|
||||
<img
|
||||
src={item.src}
|
||||
srcSet={item.srcSet}
|
||||
sizes={item.sizes}
|
||||
width={item.width}
|
||||
height={item.height}
|
||||
alt={item.alt ?? ""}
|
||||
title={item.title}
|
||||
className={cx(
|
||||
"h-(--logoloop-logoHeight) w-auto block object-contain",
|
||||
"[-webkit-user-drag:none] pointer-events-none",
|
||||
"[image-rendering:-webkit-optimize-contrast]",
|
||||
"motion-reduce:transition-none",
|
||||
scaleOnHover &&
|
||||
"transition-transform duration-300 ease-in-out group-hover/item:scale-120",
|
||||
)}
|
||||
src={(item as any).src}
|
||||
srcSet={(item as any).srcSet}
|
||||
sizes={(item as any).sizes}
|
||||
width={(item as any).width}
|
||||
height={(item as any).height}
|
||||
alt={(item as any).alt ?? ""}
|
||||
title={(item as any).title}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
draggable={false}
|
||||
/>
|
||||
);
|
||||
|
||||
const itemAriaLabel = isNodeItem
|
||||
? (item.ariaLabel ?? item.title)
|
||||
: (item.alt ?? item.title);
|
||||
const itemContent = item.href ? (
|
||||
? ((item as any).ariaLabel ?? (item as any).title)
|
||||
: ((item as any).alt ?? (item as any).title);
|
||||
|
||||
const inner = (item as any).href ? (
|
||||
<a
|
||||
className="logoloop__link"
|
||||
href={item.href}
|
||||
className={cx(
|
||||
"inline-flex items-center no-underline rounded",
|
||||
"transition-opacity duration-200 ease-linear",
|
||||
"hover:opacity-80",
|
||||
"focus-visible:outline focus-visible:outline-current focus-visible:outline-offset-2",
|
||||
)}
|
||||
href={(item as any).href}
|
||||
aria-label={itemAriaLabel || "logo link"}
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
@@ -316,20 +423,29 @@ export const LogoLoop = memo(
|
||||
) : (
|
||||
content
|
||||
);
|
||||
|
||||
return (
|
||||
<li className="logoloop__item" key={key} role="listitem">
|
||||
{itemContent}
|
||||
<li
|
||||
className={cx(
|
||||
"flex-none text-(length:--logoloop-logoHeight) leading-none",
|
||||
isVertical ? "mb-(--logoloop-gap)" : "mr-(--logoloop-gap)",
|
||||
scaleOnHover && "overflow-visible group/item",
|
||||
)}
|
||||
key={key}
|
||||
role="listitem"
|
||||
>
|
||||
{inner}
|
||||
</li>
|
||||
);
|
||||
},
|
||||
[renderItem],
|
||||
[isVertical, scaleOnHover, renderItem],
|
||||
);
|
||||
|
||||
const logoLists = useMemo(
|
||||
() =>
|
||||
Array.from({ length: copyCount }, (_, copyIndex) => (
|
||||
<ul
|
||||
className="logoloop__list"
|
||||
className={cx("flex items-center", isVertical && "flex-col")}
|
||||
key={`copy-${copyIndex}`}
|
||||
role="list"
|
||||
aria-hidden={copyIndex > 0}
|
||||
@@ -340,11 +456,11 @@ export const LogoLoop = memo(
|
||||
)}
|
||||
</ul>
|
||||
)),
|
||||
[copyCount, logos, renderLogoItem],
|
||||
[copyCount, logos, renderLogoItem, isVertical],
|
||||
);
|
||||
|
||||
const containerStyle = useMemo(
|
||||
() => ({
|
||||
(): React.CSSProperties => ({
|
||||
width: isVertical
|
||||
? toCssLength(width) === "100%"
|
||||
? undefined
|
||||
@@ -359,13 +475,61 @@ export const LogoLoop = memo(
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
className={rootClassName}
|
||||
className={rootClasses}
|
||||
style={containerStyle}
|
||||
role="region"
|
||||
aria-label={ariaLabel}
|
||||
>
|
||||
{fadeOut && (
|
||||
<>
|
||||
{isVertical ? (
|
||||
<>
|
||||
<div
|
||||
aria-hidden
|
||||
className={cx(
|
||||
"pointer-events-none absolute inset-x-0 top-0 z-10",
|
||||
"h-[clamp(24px,8%,120px)]",
|
||||
"bg-[linear-gradient(to_bottom,var(--logoloop-fadeColor,var(--logoloop-fadeColorAuto))_0%,rgba(0,0,0,0)_100%)]",
|
||||
)}
|
||||
/>
|
||||
<div
|
||||
aria-hidden
|
||||
className={cx(
|
||||
"pointer-events-none absolute inset-x-0 bottom-0 z-10",
|
||||
"h-[clamp(24px,8%,120px)]",
|
||||
"bg-[linear-gradient(to_top,var(--logoloop-fadeColor,var(--logoloop-fadeColorAuto))_0%,rgba(0,0,0,0)_100%)]",
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<div
|
||||
aria-hidden
|
||||
className={cx(
|
||||
"pointer-events-none absolute inset-y-0 left-0 z-10",
|
||||
"w-[clamp(24px,8%,120px)]",
|
||||
"bg-[linear-gradient(to_right,var(--logoloop-fadeColor,var(--logoloop-fadeColorAuto))_0%,rgba(0,0,0,0)_100%)]",
|
||||
)}
|
||||
/>
|
||||
<div
|
||||
aria-hidden
|
||||
className={cx(
|
||||
"pointer-events-none absolute inset-y-0 right-0 z-10",
|
||||
"w-[clamp(24px,8%,120px)]",
|
||||
"bg-[linear-gradient(to_left,var(--logoloop-fadeColor,var(--logoloop-fadeColorAuto))_0%,rgba(0,0,0,0)_100%)]",
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
<div
|
||||
className="logoloop__track"
|
||||
className={cx(
|
||||
"flex will-change-transform select-none relative z-0",
|
||||
"motion-reduce:transform-none",
|
||||
isVertical ? "flex-col h-max w-full" : "flex-row w-max",
|
||||
)}
|
||||
ref={trackRef}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
|
||||
Reference in New Issue
Block a user