how to reduce the gap between the images with the continuous loop. // Start of Selection…
- User
how to reduce the gap between the images with the continuous loop.
// Start of Selection import React, { useState, useEffect, useCallback, useRef } from "react"; import { degreesToRadians } from "popmotion"; import { motion, AnimatePresence } from "framer-motion"; import Image from "next/image"; import { Easings } from "@/lib/utils";
interface ProjectImage { id: number; url: string; title: string; subtitle: string; width: number; x: number; y: number; angle: number; }
interface Project { id: number; name: string; images: ProjectImage[]; }
// Constant project data defined outside the component const PROJECTS: Project[] = [ { id: 1, name: "Project Alpha", images: [ { id: 1, url:
https://picsum.photos/800/400?random=1, title: "Alpha Main View", subtitle: "Frontend dashboard", width: 138.38, x: 0, y: 0, angle: 0, }, { id: 2, url:https://picsum.photos/600/400?random=2, title: "Alpha User Profile", subtitle: "User settings page", width: 138.38, x: 0, y: 0, angle: 0, }, { id: 3, url:https://picsum.photos/700/400?random=3, title: "Alpha Analytics", subtitle: "Data visualization", width: 138.38, x: 0, y: 0, angle: 0, }, ], }, { id: 2, name: "Project Beta", images: [ { id: 4, url:https://picsum.photos/750/400?random=4, title: "Beta Homepage", subtitle: "Responsive design", width: 138.38, x: 0, y: 0, angle: 0, }, { id: 5, url:https://picsum.photos/650/400?random=5, title: "Beta Mobile App", subtitle: "iOS interface", width: 138.38, x: 0, y: 0, angle: 0, }, ], }, { id: 3, name: "Project Gamma", images: [ { id: 6, url:https://picsum.photos/900/400?random=6, title: "Gamma 3D Model", subtitle: "Product showcase", width: 138.38, x: 0, y: 0, angle: 0, }, { id: 7, url:https://picsum.photos/550/400?random=7, title: "Gamma AR View", subtitle: "Augmented reality feature", width: 138.38, x: 0, y: 0, angle: 0, }, { id: 8, url:https://picsum.photos/720/400?random=8, title: "Gamma User Testing", subtitle: "Usability study results", width: 138.38, x: 0, y: 0, angle: 0, }, ], }, ];const ProjectImageGallery: React.FC = () => { const [projects, setProjects] = useState<Project[]>(PROJECTS); const [rotation, setRotation] = useState(0); const [startAngle, setStartAngle] = useState(degreesToRadians(-2)); const [endAngle, setEndAngle] = useState(degreesToRadians(182)); const containerRef = useRef(null); const [ellipseWidth, setEllipseWidth] = useState(2700); const [ellipseHeight, setEllipseHeight] = useState(400); const [visibleImages, setVisibleImages] = useState<ProjectImage[]>([]);
// Update ellipse dimensions based on parent size useEffect(() => { const updateSize = () => { if (containerRef.current) { const { clientWidth, clientHeight } = containerRef.current; setEllipseWidth(clientWidth); setEllipseHeight(clientHeight); } };
updateSize(); window.addEventListener("resize", updateSize); return () => window.removeEventListener("resize", updateSize); - Assistant