diff --git a/client/src/components/game/game-renderer.tsx b/client/src/components/game/game-renderer.tsx index 8c494b12..55028b76 100644 --- a/client/src/components/game/game-renderer.tsx +++ b/client/src/components/game/game-renderer.tsx @@ -105,16 +105,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(