From 69141540852f4d8ef2ca44b265709012356577e6 Mon Sep 17 00:00:00 2001 From: Aidan Blum Levine Date: Thu, 30 Jan 2025 19:17:21 -0500 Subject: [PATCH 1/2] bug fix bug_fix_important --- client/src/components/game/game-renderer.tsx | 25 +++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/client/src/components/game/game-renderer.tsx b/client/src/components/game/game-renderer.tsx index 8c494b12..d132ceb6 100644 --- a/client/src/components/game/game-renderer.tsx +++ b/client/src/components/game/game-renderer.tsx @@ -85,6 +85,7 @@ const GameRendererCanvases: React.FC<{ children: React.ReactNode }> = ({ childre }, []) return (
{ // Dont clear the GameRenderer selection @@ -105,16 +106,22 @@ const ZoomableGameRenderer: React.FC<{ const playable = round.match.game.playable // playable unless we are in the map editor React.useEffect(() => { - if (spaceRef.current && spaceRef.current.viewPort) { - if (!playable) { - // disable zooming and panning in map editor - const vp = spaceRef.current.viewPort - vp.setBounds({ x: [0, vp.containerWidth], y: [0, vp.containerHeight], zoom: [1, 1] }) - } else { - const vp = spaceRef.current.viewPort - vp.setBounds({ x: [-10000, 10000], y: [-10000, 10000], zoom: [0.1, 10] }) + const handleResize = () => { + if (spaceRef.current && spaceRef.current.viewPort) { + if (!playable) { + // disable zooming and panning in the map editor + const vp = spaceRef.current.viewPort + vp.setBounds({ x: [0, vp.containerWidth], y: [0, vp.containerHeight], zoom: [1, 1] }) + } else { + const vp = spaceRef.current.viewPort + vp.setBounds({ x: [-10000, 10000], y: [-10000, 10000], zoom: [0.1, 10] }) + } } } + handleResize() + + window.addEventListener('resize', handleResize) + return () => window.removeEventListener('resize', handleResize) }, [playable]) const gameAreaRect = spaceRef.current?.viewPort?.translateClientRectToVirtualSpace( @@ -146,7 +153,7 @@ const ZoomableGameRenderer: React.FC<{ React.useEffect(resetCamera, [match]) return ( -
GameRenderer.clearSelected()}> +
GameRenderer.clearSelected()} className="w-full h-screen"> { From b0467db83177e066b80df5a1bcaaffba13c7a441 Mon Sep 17 00:00:00 2001 From: Aidan Blum Levine Date: Thu, 30 Jan 2025 19:19:22 -0500 Subject: [PATCH 2/2] better bug fix important more impportant --- client/src/components/game/game-renderer.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/src/components/game/game-renderer.tsx b/client/src/components/game/game-renderer.tsx index d132ceb6..55028b76 100644 --- a/client/src/components/game/game-renderer.tsx +++ b/client/src/components/game/game-renderer.tsx @@ -85,7 +85,6 @@ const GameRendererCanvases: React.FC<{ children: React.ReactNode }> = ({ childre }, []) return (
{ // Dont clear the GameRenderer selection @@ -153,7 +152,7 @@ const ZoomableGameRenderer: React.FC<{ React.useEffect(resetCamera, [match]) return ( -
GameRenderer.clearSelected()} className="w-full h-screen"> +
GameRenderer.clearSelected()}> {