From 8704cf6234eaee39659a76909b1f42e3a25bd3ca Mon Sep 17 00:00:00 2001 From: Meysam Parvizi Date: Sat, 10 Oct 2026 02:22:37 +0200 Subject: [PATCH] fix(site): allow zooming in after "Show the whole page" The whole-page view sits below the minimum zoom, so every zoom-in step was rejected as out of range. Limits now only stop steps that go further out of range, and zooming out can reach the whole-page view. --- site/mapview.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/site/mapview.js b/site/mapview.js index a26322e..5bdd21a 100644 --- a/site/mapview.js +++ b/site/mapview.js @@ -423,10 +423,11 @@ export function createMapView({ root, plan, data, build, onSelect }) { fitButton.title = 'Show the whole page'; } + const pageFitWidth = (size) => Math.max(page.w, (page.h + 40) / (size ? size.h / size.w : page.h / page.w)) + 40; + function fitPage() { const size = canvasSize(); - const aspect = size ? size.h / size.w : page.h / page.w; - const width = Math.max(page.w, (page.h + 40) / aspect) + 40; + const width = pageFitWidth(size); fitMode = 'page'; setView({ x: (page.w - width) / 2, y: 0, w: width }); fitButton.title = 'Fit the width'; @@ -446,7 +447,9 @@ export function createMapView({ root, plan, data, build, onSelect }) { const size = canvasSize(); if (!size) return; const scale = (size.w / v.w) * factor; - if (scale < (size.w / page.w) * MIN_ZOOM || scale > MAX_ZOOM) return; + // Limits only stop a step that goes further out of range; the whole-page view is always reachable. + const minScale = Math.min((size.w / page.w) * MIN_ZOOM, size.w / pageFitWidth(size), size.w / v.w); + if (factor > 1 ? scale > MAX_ZOOM : scale < minScale) return; const [px, py] = clientX == null ? [v.x + v.w / 2, v.y + v.h / 2] : toChart(clientX, clientY); fitMode = 'custom'; setView({ x: px - (px - v.x) / factor, y: py - (py - v.y) / factor, w: v.w / factor });