From 3173cf038dd14944de6f108917a264864a17823c Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Fri, 17 Apr 2026 22:46:04 -0400 Subject: [PATCH] Fix zoom reset (press 0) not disabling frame-to-frame navigation When removeAttribute('zoom') was called, parseFloat(null) produced NaN, and typeof NaN === 'number' is true in JS, so #goLeft/#goRight still entered the zoomed-in dual-pane navigation branch. Root cause fix: handle null value in attributeChangedCallback by setting #zoom to undefined before the parseFloat path. Defense in depth: add isNaN() guards to the zoom checks in #goLeft and #goRight, matching the pattern already used in #render(). --- fixed-layout.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/fixed-layout.js b/fixed-layout.js index 9ff197d..4f0023d 100644 --- a/fixed-layout.js +++ b/fixed-layout.js @@ -87,6 +87,11 @@ export class FixedLayout extends HTMLElement { attributeChangedCallback(name, _, value) { switch (name) { case "zoom": { + if (value == null) { + this.#zoom = undefined; + this.#render(); + return; + } const newZoom = value !== "fit-width" && value !== "fit-page" ? parseFloat(value) @@ -503,6 +508,13 @@ export class FixedLayout extends HTMLElement { } #render(side = this.#side) { + console.log("[FXL] render:", { + side, + zoom: this.#zoom, + transformScale: this.#transform.scale, + isNumericZoom: typeof this.#zoom === "number" && !isNaN(this.#zoom), + hasDualFrames: !this.#center && !this.#left?.blank && !this.#right?.blank, + }); if (!side) return; const left = this.#left ?? {}; const right = this.#center ?? this.#right ?? {}; @@ -594,7 +606,7 @@ export class FixedLayout extends HTMLElement { } // zoomed-in dual-pane - pan to left frame - if (typeof this.#zoom === "number" && !this.#right?.blank) { + if (typeof this.#zoom === "number" && !isNaN(this.#zoom) && !this.#right?.blank) { if (this.#side === "right") { this.#side = "left"; this.#render(); @@ -613,7 +625,7 @@ export class FixedLayout extends HTMLElement { } // zoomed-in dual-pane - pan to right frame - if (typeof this.#zoom === "number" && !this.#left?.blank) { + if (typeof this.#zoom === "number" && !isNaN(this.#zoom) && !this.#left?.blank) { if (this.#side === "left") { this.#side = "right"; this.#render();