fix origin
Some checks failed
Test / test (push) Has been cancelled

This commit is contained in:
2026-06-21 09:09:19 +02:00
parent 064c9b5758
commit 7a850937b0
2 changed files with 32 additions and 10 deletions

View File

@@ -1294,7 +1294,6 @@
function onCanvasClick(evt) { function onCanvasClick(evt) {
if (!hasFloorPlan() || state.readOnly || state.pointerMoved) return; if (!hasFloorPlan() || state.readOnly || state.pointerMoved) return;
if (evt.target?.closest?.(".mapEditorOriginHit")) return;
const pt = imagePointFromEvent(evt); const pt = imagePointFromEvent(evt);
if (!pt) return; if (!pt) return;
dismissCanvasTip(); dismissCanvasTip();
@@ -1549,6 +1548,29 @@
if (originLabelEl) originLabelEl.setAttribute("aria-hidden", visible ? "false" : "true"); 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() { function updateOriginMarker() {
if (!originEl) return; if (!originEl) return;
const geo = Geo(); const geo = Geo();
@@ -2070,6 +2092,7 @@
viewportEl?.addEventListener("mousemove", (evt) => { viewportEl?.addEventListener("mousemove", (evt) => {
updateStatusBar({ x: evt.clientX, y: evt.clientY }); updateStatusBar({ x: evt.clientX, y: evt.clientY });
updateOriginLabelFromPointer(evt);
if (state.draft?.kind === "shape" && isDrawTool(state.activeTool)) { if (state.draft?.kind === "shape" && isDrawTool(state.activeTool)) {
const pt = imagePointFromEvent(evt); const pt = imagePointFromEvent(evt);
const obj = Objects(); const obj = Objects();
@@ -2095,6 +2118,7 @@
viewportEl?.addEventListener("mouseleave", () => { viewportEl?.addEventListener("mouseleave", () => {
updateStatusBar(); updateStatusBar();
setOriginLabelVisible(false);
}); });
viewportEl?.addEventListener("mousedown", (evt) => { viewportEl?.addEventListener("mousedown", (evt) => {
@@ -2158,8 +2182,6 @@
} }
function bindEvents() { function bindEvents() {
originHitEl?.addEventListener("mouseenter", () => setOriginLabelVisible(true));
originHitEl?.addEventListener("mouseleave", () => setOriginLabelVisible(false));
originHitEl?.addEventListener("focus", () => setOriginLabelVisible(true)); originHitEl?.addEventListener("focus", () => setOriginLabelVisible(true));
originHitEl?.addEventListener("blur", () => setOriginLabelVisible(false)); originHitEl?.addEventListener("blur", () => setOriginLabelVisible(false));

View File

@@ -4168,17 +4168,17 @@ body.auth-readonly-maps-page .mapsMirMapMenuCancelBtn {
.mapEditorOriginHit { .mapEditorOriginHit {
position: absolute; position: absolute;
left: -18px; left: -6px;
top: -18px; top: -6px;
width: 36px; width: 12px;
height: 36px; height: 12px;
padding: 0; padding: 0;
margin: 0; margin: 0;
border: none; border: none;
border-radius: 0; border-radius: 50%;
background: transparent; background: transparent;
pointer-events: auto; pointer-events: none;
cursor: help; cursor: inherit;
z-index: 5; z-index: 5;
appearance: none; appearance: none;
font: inherit; font: inherit;