From 85b00e56a034713a8e34f9e10423ae14dbc810e0 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 21 Aug 2023 22:03:18 +0100 Subject: js: prefer some puzzle size even if loading isn't complete The js_canvas_get_preferred_size() function was declining to suggest a size for the puzzle if document.readyState wasn't "complete". I think my idea here was that if the document wasn't fully loaded then I couldn't trust the size of the containing
. While this was true, declining to provide a size didn't help much since the puzzle still needed a size, and the size of the containing
was the best guess we had. Now that function always returns the size of the containing
if it exists. This appears to mean that puzzles don't show a brief flash of being the wrong size on KaiOS. That was particularly visible with Flood, where the wrong-size version had borders around the tiles that the right-size version lacked. The containing
isn't used on the standard Web versions, so there's no change to behaviour there. --- emcclib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emcclib.js b/emcclib.js index d1bea08..1a5e04c 100644 --- a/emcclib.js +++ b/emcclib.js @@ -612,7 +612,7 @@ mergeInto(LibraryManager.library, { * alone and return false. */ js_canvas_get_preferred_size: function(wp, hp) { - if (document.readyState == "complete" && containing_div !== null) { + if (containing_div !== null) { var dpr = window.devicePixelRatio || 1; setValue(wp, containing_div.clientWidth * dpr, "i32"); setValue(hp, containing_div.clientHeight * dpr, "i32"); -- cgit v1.1