"use client"; import { motion } from "framer-motion"; import React from "react"; export interface MarqueeImage { src: string; alt: string; href?: string; target?: "_blank" | "_self" | "_parent" | "_top"; } export interface ThreeDMarqueeProps { images: MarqueeImage[]; className?: string; cols?: number; // default is 4 onImageClick?: (image: MarqueeImage, index: number) => void; } export const ThreeDMarquee: React.FC = ({ images, className = "", cols = 4, onImageClick, }) => { // Clone the image list twice const duplicatedImages = [...images, ...images]; const groupSize = Math.ceil(duplicatedImages.length / cols); const imageGroups = Array.from({ length: cols }, (_, index) => duplicatedImages.slice(index * groupSize, (index + 1) * groupSize) ); const handleImageClick = (image: MarqueeImage, globalIndex: number) => { if (onImageClick) { onImageClick(image, globalIndex); } else if (image.href) { window.open(image.href, image.target || "_self"); } }; return (
{imageGroups.map((imagesInGroup, idx) => (
{imagesInGroup.map((image, imgIdx) => { const globalIndex = idx * groupSize + imgIdx; const isClickable = image.href || onImageClick; return (
handleImageClick(image, globalIndex)} />
); })} ))}
); };