forked from emre/www_projectmycelium_com
- Added agent1.png image asset - Refactored InfiniteMovingCards component with cleaner animation logic and improved duplication handling - Changed default speed from "fast" to "slow" and simplified animation setup - Updated AgentBento title from "Augmented Intelligence Fabric" to "Intelligence Fabric" - Increased Homepod vertical padding on large screens (lg:py-16 to lg:py-24) - Removed "Feature" label from PodsFeatures use
74 lines
1.7 KiB
TypeScript
74 lines
1.7 KiB
TypeScript
"use client";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
import React, { useEffect, useRef, useState } from "react";
|
|
|
|
export const InfiniteMovingCards = ({
|
|
items,
|
|
direction = "left",
|
|
speed = "slow",
|
|
pauseOnHover = true,
|
|
className,
|
|
}: {
|
|
items: React.ReactNode[];
|
|
direction?: "left" | "right";
|
|
speed?: "fast" | "normal" | "slow";
|
|
pauseOnHover?: boolean;
|
|
className?: string;
|
|
}) => {
|
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
const scrollerRef = useRef<HTMLUListElement>(null);
|
|
const [isReady, setIsReady] = useState(false);
|
|
|
|
useEffect(() => {
|
|
if (!scrollerRef.current) return;
|
|
|
|
const children = Array.from(scrollerRef.current.children);
|
|
|
|
// duplicate each item ONCE
|
|
children.forEach((item) => {
|
|
const clone = item.cloneNode(true);
|
|
scrollerRef.current!.appendChild(clone);
|
|
});
|
|
|
|
// set speed variable
|
|
const duration =
|
|
speed === "fast" ? "20s" : speed === "normal" ? "40s" : "80s";
|
|
|
|
containerRef.current?.style.setProperty(
|
|
"--animation-duration",
|
|
duration
|
|
);
|
|
|
|
// set direction variable
|
|
containerRef.current?.style.setProperty(
|
|
"--animation-direction",
|
|
direction === "left" ? "forwards" : "reverse"
|
|
);
|
|
|
|
setIsReady(true);
|
|
}, [direction, speed]);
|
|
|
|
return (
|
|
<div
|
|
ref={containerRef}
|
|
className={cn("scroller relative z-20 overflow-hidden", className)}
|
|
>
|
|
<ul
|
|
ref={scrollerRef}
|
|
className={cn(
|
|
"flex w-max shrink-0 gap-16 py-4",
|
|
isReady && "animate-infinite-scroll",
|
|
pauseOnHover && "hover:[animation-play-state:paused]"
|
|
)}
|
|
>
|
|
{items.map((item, i) => (
|
|
<li key={i} className="flex-shrink-0">
|
|
{item}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
);
|
|
};
|