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 <div>.  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 <div> was the best guess
we had.

Now that function always returns the size of the containing <div> 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 <div> isn't used on the
standard Web versions, so there's no change to behaviour there.
This commit is contained in:
Ben Harris
2023-08-21 22:03:18 +01:00
parent 26a3b98f4f
commit 85b00e56a0

View File

@ -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");