aboutsummaryrefslogtreecommitdiff
path: root/web/pw-visualizer
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-11-12 12:51:58 +0100
committerIlion Beyst <ilion.beyst@gmail.com>2022-11-12 12:51:58 +0100
commitb0530be5010494f2db3deded340c16a6dc3cbe56 (patch)
treea18bd1226ee3cf0be73316cbef7cd357285ad489 /web/pw-visualizer
parentd140759ea539c43f3b9a50b37719b34b58ba430e (diff)
downloadplanetwars.dev-b0530be5010494f2db3deded340c16a6dc3cbe56.tar.xz
planetwars.dev-b0530be5010494f2db3deded340c16a6dc3cbe56.zip
collapse PlayerLog entries
Diffstat (limited to 'web/pw-visualizer')
-rw-r--r--web/pw-visualizer/src/index.ts21
1 files changed, 10 insertions, 11 deletions
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) {