Skip to content

Commit

Permalink
Fix aspectRatio 1:1 (#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
DTTerastar authored Nov 18, 2024
1 parent 9ce835e commit 9b99af9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/ui/src/lib/Map.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
$: floor = $config?.floors.find((f) => f.id === floorId) ?? $config?.floors.find((f) => f != null);
$: bounds = floor?.bounds;
$: squareBounds = bounds ? makeSquareBounds(bounds) : undefined;
function makeSquareBounds(bounds: number[][]): number[][] {
const maxDim = Math.max(bounds[1][0], bounds[1][1]);
return [
[bounds[0][0], bounds[0][1], bounds[0][2]],
[maxDim, maxDim, bounds[1][2]]
];
}
const handler = zoom()
.scaleExtent([0.5, 40])
Expand Down Expand Up @@ -66,7 +75,7 @@
y="1"
xRange={getXRange}
yRange={getYRange}
flatData={bounds}
flatData={squareBounds}
padding={{ top: 16, left: 16, bottom: 16, right: 16 }}
>
<Svg bind:element={svg}>
Expand Down

0 comments on commit 9b99af9

Please sign in to comment.