From b0530be5010494f2db3deded340c16a6dc3cbe56 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Sat, 12 Nov 2022 12:51:58 +0100 Subject: collapse PlayerLog entries --- web/pw-visualizer/src/index.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'web/pw-visualizer/src/index.ts') diff --git a/web/pw-visualizer/src/index.ts b/web/pw-visualizer/src/index.ts index 74b2319..8159134 100644 --- a/web/pw-visualizer/src/index.ts +++ b/web/pw-visualizer/src/index.ts @@ -51,6 +51,15 @@ export function set_loading(loading: boolean) { } } +// this function should be called after resizes happen +function do_resize() { + resizeCanvasToDisplaySize(CANVAS); + + if (game_instance) { + game_instance.on_resize(); + } +} + function clamp(min: number, max: number, value: number): number { if (value < min) { return min; @@ -103,17 +112,7 @@ export function init() { GL.enable(GL.BLEND); GL.blendFunc(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA); - window.addEventListener( - "resize", - function () { - resizeCanvasToDisplaySize(CANVAS); - - if (game_instance) { - game_instance.on_resize(); - } - }, - { capture: false, passive: true } - ); + new ResizeObserver(do_resize).observe(ELEMENTS["canvas"]); ELEMENTS["turnSlider"].oninput = function () { if (game_instance) { -- cgit v1.2.3