aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2023-08-21 22:03:18 +0100
committerBen Harris <bjh21@bjh21.me.uk>2023-08-21 22:06:21 +0100
commit85b00e56a034713a8e34f9e10423ae14dbc810e0 (patch)
treed6a8aed25d23f6ae9592bb51338b53f329ba9af6
parent26a3b98f4f30de1f3faf0bb97eeeb8403864b5d3 (diff)
downloadpuzzles-85b00e56a034713a8e34f9e10423ae14dbc810e0.zip
puzzles-85b00e56a034713a8e34f9e10423ae14dbc810e0.tar.gz
puzzles-85b00e56a034713a8e34f9e10423ae14dbc810e0.tar.bz2
puzzles-85b00e56a034713a8e34f9e10423ae14dbc810e0.tar.xz
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.
-rw-r--r--emcclib.js2
1 files changed, 1 insertions, 1 deletions
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");