"use client"; import { useState } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { ArrowRight } from "lucide-react"; import { MobileFrame } from "./MobileFrame"; export default function MobileStack({ images }: { images: string[] }) { const [currentIndex, setCurrentIndex] = useState(0); const DRAG_THRESHOLD = -150; const getRelativeIndex = (index: number) => { const len = images.length; return (index - currentIndex + len) % len; }; const next = () => setCurrentIndex((prev) => (prev + 1) % images.length); return (
{images.map((img, index) => { const relIndex = getRelativeIndex(index); const isTop = relIndex === 0; const xOffset = relIndex * 90; if (relIndex > 5) return null; return ( { if (isTop && info.offset.x < DRAG_THRESHOLD) { next(); } }} onDragEnd={(_, info) => { // Backup check for quick flicks if (isTop && info.offset.x < -100) { next(); } }} onClick={() => !isTop && setCurrentIndex(index)} className="absolute" >
App Screenshot
); })}
{/* Navigation Button */}
); }