From a8a7718b50982b72f337b5daf686ef542e0d9411 Mon Sep 17 00:00:00 2001 From: goldjohn6 Date: Sat, 21 Nov 2026 15:02:26 -0800 Subject: [PATCH] Map zoom (#176) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Zoom the map: buttons, pinch, wheel, and drag to pan Players asked for a way to zoom in after the board is fitted to the screen. This adds a zoom on the map alone, on top of the fitted layout, in both the desktop and portrait layouts. - + / − / reset buttons in the map's top-right corner, sized in screen pixels so they stay thumb-sized on a phone. - Two-finger pinch on touch screens zooms the map, not the page. One finger pans once zoomed; at the fitted size it still scrolls the page. - Trackpad pinch (ctrl+wheel) everywhere; a plain wheel also zooms on desktop, where the board fits the window. - Mouse drag pans when zoomed. A press that moves more than 6 px is a pan, and the click that follows it is swallowed, so a drag never builds a city. - Clamped between the fit and 4x, and the zoomed map always covers its own box. It is clipped to that box, so it never covers the market or player boards. The zoom layer sits outside the measured map slot, so the layout's getBBox() measurement never sees it. The maths is in util/map-zoom.ts with unit tests. Co-Authored-By: Claude Opus 5.5 * Map zoom: a faint outline and a minimap while zoomed Asked for with older players in mind, so a zoomed map never leaves anyone lost. Nothing changes at the fitted size. While zoomed: - a faint white outline round the map's box, so it reads as a zoomed view; - a small overview of the whole map in the bottom-left corner (the buttons are top-right), rounded, with an orange box over the part on screen. Tapping the overview centres the view there. The overview is a of the map slot, so it always matches the board. It is sized in screen pixels, from 72 to 128 px on its long side, and keeps the map's own proportions in both the desktop and portrait layouts. Gestures never start on the overview or the buttons. Co-Authored-By: Claude Opus 5.5 * Map zoom: a plain wheel scrolls the page, Ctrl+wheel zooms Someone scrolling down to the resources or the chat must never zoom by accident, so a plain wheel over the map always scrolls the page. It also shows a brief hint, "Hold Ctrl and scroll to zoom" (⌘ on a Mac), the way embedded maps do. Ctrl/⌘ + wheel and trackpad pinch zoom the map, and the + / − tooltips mention both. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- viewer/src/components/Game.vue | 606 +++++++++++++++++++++++++++-- viewer/src/util/map-zoom.ts | 115 ++++++ viewer/tests/unit/map-zoom.spec.ts | 104 +++++ 3 files changed, 803 insertions(+), 22 deletions(-) create mode 100644 viewer/src/util/map-zoom.ts create mode 100644 viewer/tests/unit/map-zoom.spec.ts diff --git a/viewer/src/components/Game.vue b/viewer/src/components/Game.vue index 15efe23..8c7245b 100644 --- a/viewer/src/components/Game.vue +++ b/viewer/src/components/Game.vue @@ -25,6 +25,12 @@ :viewBox="sceneViewBox" :style="{ width: '100%', aspectRatio: sceneViewBox.split(' ').slice(2).join(' / ') }" preserveAspectRatio="xMidYMin meet" + @wheel="onSceneWheel" + @pointerdown="onScenePointerDown" + @touchstart="onSceneTouchStart" + @touchmove="onSceneTouchMove" + @touchend="onSceneTouchEnd" + @touchcancel="onSceneTouchEnd" > @@ -37,7 +43,8 @@ behind every game component. Toggling them never changes the playable network's bounds, scale or position. -->