From 922e181532d9f8bcf2a037e7be9a514e44bbdbab Mon Sep 17 00:00:00 2001 From: Yui Date: Thu, 5 Sep 2024 00:16:05 +0300 Subject: [PATCH] Resizing the canvas using js/css now triggers the resize event --- js/gl.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/gl.js b/js/gl.js index 4358b7c3..1d4fd529 100644 --- a/js/gl.js +++ b/js/gl.js @@ -420,13 +420,14 @@ function _webglGet(name_, p, type) { var Module; var wasm_exports; -function resize(canvas, on_resize) { +function resize(canvas, on_resize, force = false) { var dpr = dpi_scale(); var displayWidth = canvas.clientWidth * dpr; var displayHeight = canvas.clientHeight * dpr; if (canvas.width != displayWidth || - canvas.height != displayHeight) { + canvas.height != displayHeight || + force) { canvas.width = displayWidth; canvas.height = displayHeight; if (on_resize != undefined) @@ -1263,6 +1264,9 @@ var importObject = { wasm_exports.touch(SAPP_EVENTTYPE_TOUCHES_MOVED, touch.identifier, relative_position.x, relative_position.y); } }); + new ResizeObserver(function (_entries) { + resize(canvas, wasm_exports.resize, true); + }).observe(canvas); window.onresize = function () { resize(canvas, wasm_exports.resize);