diff --git a/www/map-editor.js b/www/map-editor.js index 0ee0296..233948e 100644 --- a/www/map-editor.js +++ b/www/map-editor.js @@ -1294,7 +1294,6 @@ function onCanvasClick(evt) { if (!hasFloorPlan() || state.readOnly || state.pointerMoved) return; - if (evt.target?.closest?.(".mapEditorOriginHit")) return; const pt = imagePointFromEvent(evt); if (!pt) return; dismissCanvasTip(); @@ -1549,6 +1548,29 @@ if (originLabelEl) originLabelEl.setAttribute("aria-hidden", visible ? "false" : "true"); } + function originPixelOnSheet() { + const geo = Geo(); + const { width, height } = floorPlanSize(); + if (!state.showOrigin || !geo || !hasFloorPlan() || !width || !height) return null; + return geo.worldToPixel(mapMetaForOriginDisplay(), width, height, 0, 0); + } + + /** Show origin label when pointer is near world (0,0) — without blocking map tools. */ + function updateOriginLabelFromPointer(evt) { + if (!state.showOrigin || originEl?.hidden) { + setOriginLabelVisible(false); + return; + } + const originPt = originPixelOnSheet(); + const imgPt = imagePointFromEvent(evt); + if (!originPt || !imgPt) { + setOriginLabelVisible(false); + return; + } + const dist = Math.hypot(imgPt.x - originPt.x, imgPt.y - originPt.y); + setOriginLabelVisible(dist <= 14); + } + function updateOriginMarker() { if (!originEl) return; const geo = Geo(); @@ -2070,6 +2092,7 @@ viewportEl?.addEventListener("mousemove", (evt) => { updateStatusBar({ x: evt.clientX, y: evt.clientY }); + updateOriginLabelFromPointer(evt); if (state.draft?.kind === "shape" && isDrawTool(state.activeTool)) { const pt = imagePointFromEvent(evt); const obj = Objects(); @@ -2095,6 +2118,7 @@ viewportEl?.addEventListener("mouseleave", () => { updateStatusBar(); + setOriginLabelVisible(false); }); viewportEl?.addEventListener("mousedown", (evt) => { @@ -2158,8 +2182,6 @@ } function bindEvents() { - originHitEl?.addEventListener("mouseenter", () => setOriginLabelVisible(true)); - originHitEl?.addEventListener("mouseleave", () => setOriginLabelVisible(false)); originHitEl?.addEventListener("focus", () => setOriginLabelVisible(true)); originHitEl?.addEventListener("blur", () => setOriginLabelVisible(false)); diff --git a/www/style.css b/www/style.css index 20697ae..cb7d5ff 100644 --- a/www/style.css +++ b/www/style.css @@ -4168,17 +4168,17 @@ body.auth-readonly-maps-page .mapsMirMapMenuCancelBtn { .mapEditorOriginHit { position: absolute; - left: -18px; - top: -18px; - width: 36px; - height: 36px; + left: -6px; + top: -6px; + width: 12px; + height: 12px; padding: 0; margin: 0; border: none; - border-radius: 0; + border-radius: 50%; background: transparent; - pointer-events: auto; - cursor: help; + pointer-events: none; + cursor: inherit; z-index: 5; appearance: none; font: inherit;