From 598c0348f69e3405f7add0c83c1af5982a865493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=AA=E3=82=AD=E8=90=8C?= Date: Tue, 27 May 2025 20:20:10 +0200 Subject: [PATCH] fix viewport shrinking permanently (#113) what was happening is we were setting style.width and style.height which overrode the styles from CSS that gave us the BoundingClientRect from which we were calculating the canvas size I also added a sendViewportUpdate to prevent chunk jank --- static/canvas-renderer.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/static/canvas-renderer.js b/static/canvas-renderer.js index cfc5bb5..a8a12c1 100644 --- a/static/canvas-renderer.js +++ b/static/canvas-renderer.js @@ -40,13 +40,14 @@ class CanvasRenderer extends HTMLElement { // To properly handle DPI scaling, we want the canvas's layout size to be equal to that of // its parent container, - this.style.width = `${width}px`; - this.style.height = `${height}px`; this.canvas.width = width * window.devicePixelRatio; this.canvas.height = height * window.devicePixelRatio; // Rerender immediately after the canvas is resized, as its contents have now been invalidated. this.#render(); + + // Send a viewport update so that the server knows to send new chunks. + this.sendViewportUpdate(); } getWindowSize() {