Skip to content

Commit

Permalink
Fix coordinates (#847)
Browse files Browse the repository at this point in the history
  • Loading branch information
DTTerastar authored Nov 17, 2024
1 parent a54d3d2 commit 663bbb6
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/ui/src/lib/MapCoordinates.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
const svgElement = event.currentTarget as SVGElement;
const rect = svgElement.getBoundingClientRect();
const x = event.clientX - rect.left - 16;
const y = event.clientY - rect.top - 16;
const x = event.clientX - rect.left;
const y = event.clientY - rect.top;
const transformedX = (x - transform.x) / transform.k;
const transformedY = (y - transform.y) / transform.k;
cursorX = $xScale.invert(transformedX);
cursorY = $yScale.invert(transformedY);
cursorX = $xScale.invert((x - transform.x) / transform.k);
cursorY = $yScale.invert((y - transform.y) / transform.k);
}
</script>

Expand Down Expand Up @@ -51,4 +48,4 @@
>
X: {cursorX.toFixed(2)}, Y: {cursorY.toFixed(2)}
</text>
</g>
</g>

0 comments on commit 663bbb6

Please sign in to comment.