diff --git a/components/sections/CloudRevealSection.tsx b/components/sections/CloudRevealSection.tsx index 476b49c..87e9041 100644 --- a/components/sections/CloudRevealSection.tsx +++ b/components/sections/CloudRevealSection.tsx @@ -111,14 +111,18 @@ export default function CloudRevealSection() { // Scroll → canvas frame çiz useMotionValueEvent(scrollYProgress, 'change', (progress) => { - const frameIdx = Math.min( + const targetIdx = Math.min( Math.floor(progress * (TOTAL_FRAMES - 1)), TOTAL_FRAMES - 1 ) - const img = framesRef.current[frameIdx] + // Hedef frame yüklenmemişse geriye doğru ilk yüklü frame'i bul + let img: HTMLImageElement | null = null + for (let i = targetIdx; i >= 0; i--) { + if (framesRef.current[i]) { img = framesRef.current[i]; break } + } const canvas = canvasRef.current const ctx = canvas?.getContext('2d') - if (img && canvas && ctx) { + if (img && canvas && ctx && canvas.width > 0) { ctx.drawImage(img, 0, 0, canvas.width, canvas.height) } })