diff --git a/pitch-deck/components/slides/SDKDemoSlide.tsx b/pitch-deck/components/slides/SDKDemoSlide.tsx index b12b9e2..4565085 100644 --- a/pitch-deck/components/slides/SDKDemoSlide.tsx +++ b/pitch-deck/components/slides/SDKDemoSlide.tsx @@ -1,6 +1,6 @@ 'use client' -import { useState, useEffect, useCallback } from 'react' +import { useState, useEffect, useCallback, useRef } from 'react' import { motion, AnimatePresence } from 'framer-motion' import Image from 'next/image' import { Language } from '@/lib/types' @@ -43,6 +43,26 @@ export default function SDKDemoSlide({ lang }: SDKDemoSlideProps) { const [fullscreen, setFullscreen] = useState(false) const [autoPlay, setAutoPlay] = useState(true) + // Track which images have actually loaded so we never cross-fade to a blank + // frame. While the target image is still fetching, `shown` stays on the + // previous loaded one — this eliminates the flash of empty canvas the user + // hit on the first pass through the carousel. + const loadedRef = useRef>(new Set()) + const [shown, setShown] = useState(0) + + const handleLoaded = useCallback((idx: number) => { + loadedRef.current.add(idx) + // If the user is currently waiting on this image, reveal it immediately. + // Otherwise the preceding loaded image keeps showing — no blank flash. + if (idx === current) setShown(idx) + }, [current]) + + useEffect(() => { + if (loadedRef.current.has(current)) { + setShown(current) + } + }, [current]) + const next = useCallback(() => { setCurrent(i => (i + 1) % SCREENSHOTS.length) }, []) @@ -101,25 +121,31 @@ export default function SDKDemoSlide({ lang }: SDKDemoSlideProps) { - {/* Screenshot */} - - - {de - - + {/* Screenshot stack — all images mount at once so we can cross-fade + between them by toggling opacity. AnimatePresence mode="wait" + unmounts before the next mounts, which forces a cold fetch and + produces a blank frame; the stack avoids both. */} +
+ {SCREENSHOTS.map((s, idx) => ( +
+ {de handleLoaded(idx)} + /> +
+ ))} +
{/* Navigation arrows */}