From aba98d7b1c98b2589cb2ed2fc8522bd4d320ce8d Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Tue, 3 Nov 2026 10:23:18 +0100 Subject: [PATCH] refactor: WorldMap's layer offset computed once Co-Authored-By: Claude Opus 5.5 --- app/components/map/WorldMap.vue | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/components/map/WorldMap.vue b/app/components/map/WorldMap.vue index 6331888..f78c2b5 100644 --- a/app/components/map/WorldMap.vue +++ b/app/components/map/WorldMap.vue @@ -44,7 +44,7 @@ const lo = computed(() => props.view?.min ?? mapMin(mapSize.value)) const villageAt = computed(() => new Map((props.view?.villages ?? []).map((v) => [`${v.x}|${v.y}`, v]))) -// Whole fields touching the visible area, for the rulers. +// Whole fields touching the visible area. const x0 = computed(() => Math.max(lo.value, Math.floor(props.left))) const y0 = computed(() => Math.max(lo.value, Math.floor(props.top))) const x1 = computed(() => Math.min(lo.value + mapSize.value, Math.ceil(props.left + props.cols))) @@ -68,13 +68,16 @@ const shiftY = computed(() => RULER + Math.round(-props.top * props.field)) const layer = computed(() => { const r = region.value const F = props.field + /** The region's top-left corner on screen, from where the fields begin. */ + const x = shiftX.value - RULER + r.x0 * F + const y = shiftY.value - RULER + r.y0 * F return { width: (r.x1 - r.x0) * F, height: (r.y1 - r.y0) * F, viewBox: `${r.x0 * F} ${r.y0 * F} ${(r.x1 - r.x0) * F} ${(r.y1 - r.y0) * F}`, - x: shiftX.value - RULER + r.x0 * F, - y: shiftY.value - RULER + r.y0 * F, - transform: `translate3d(${shiftX.value - RULER + r.x0 * F}px, ${shiftY.value - RULER + r.y0 * F}px, 0)`, + x, + y, + transform: `translate3d(${x}px, ${y}px, 0)`, } })