import { motion } from "framer-motion"; import React, { useState, useEffect } from "react"; import Image from "next/image"; const CARD_OFFSET = 4; const ROTATION_FACTOR = 6; interface Card { id: number; imageUrl: string; rotation: number; } interface CardStackProps { photos: string[]; } const CardStack: React.FC = ({ photos }) => { const [cards, setCards] = useState([]); useEffect(() => { if (photos.length > 0) { const initialCards = photos.map((imageUrl, index) => ({ id: index, imageUrl: imageUrl, rotation: (index % 2 === 0 ? 1 : -1) * ROTATION_FACTOR * Math.random(), })); setCards(initialCards); } }, [photos]); const moveToEnd = (from: number) => { setCards((prevCards) => { const newCards = [...prevCards]; const item = newCards.splice(from, 1)[0]; newCards.push(item); return newCards; }); }; return ( ); }; export default CardStack;