diff --git a/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/PreviewWorkspace.tsx b/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/PreviewWorkspace.tsx index 62ce5f4d5..f9bfaa56d 100644 --- a/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/PreviewWorkspace.tsx +++ b/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/PreviewWorkspace.tsx @@ -55,6 +55,8 @@ export function PreviewWorkspace({ viewportRef.current, ); const [canvasSize, setCanvasSize] = useState({ width: 900, height: 640 }); + const canvasSizeRef = useRef(canvasSize); + canvasSizeRef.current = canvasSize; const [spaceHeld, setSpaceHeld] = useState(false); const [renderMode, setRenderMode] = useState('editor-overlay'); @@ -152,18 +154,12 @@ export function PreviewWorkspace({ height: logicalSize.height, }, canvasSize: { - width: element?.clientWidth || canvasSize.width, - height: element?.clientHeight || canvasSize.height, + width: element?.clientWidth || canvasSizeRef.current.width, + height: element?.clientHeight || canvasSizeRef.current.height, }, }), ); - }, [ - activeImageId, - canvasSize.height, - canvasSize.width, - logicalSize, - setViewport, - ]); + }, [activeImageId, logicalSize, setViewport]); const scaleViewportFromCenter = useCallback( (nextScale: number) => {