commit ac50318c68faa931c50f8521623079600bd90823
parent d04b781539f2ac135d125ed3b11099a4cd3b88d8
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Wed, 9 Oct 2024 14:57:02 -0700
Fix grid display
Add a margin to the grid because something is probably wrong with
my math and when the aspect ratio is close to 1 there is areas of
the screen with no grid.
Also hide the grid until the floorplan data is loaded so it doesn't
look so buggy when the viewbox is resized.
Diffstat:
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/files/floorplans/floorplan/editor.js b/files/floorplans/floorplan/editor.js
@@ -325,6 +325,7 @@ export class FloorplanEditor {
}
this.draw.rect().attr({ id: "grid" })
+ this.useGrid()
this.ui = {}
this.ui.bottom = this.draw.group().attr({ id: "bottom" })
@@ -488,7 +489,8 @@ export class FloorplanEditor {
let diff = val - box[swap[base]]
box[map[swap[base]]] -= diff / 2
box[swap[base]] = val
- grid.size(box.width, box.height).move(box.x, box.y)
+ const margin = 10000
+ grid.size(box.width + margin, box.height + margin).move(box.x - margin / 2, box.y - margin / 2)
}
// Should be called after each user "action"
diff --git a/files/floorplans/floorplan/main.js b/files/floorplans/floorplan/main.js
@@ -162,6 +162,7 @@ function init() {
))
}
+ editor.useGrid()
editor.draw.show()
editor.backend.pull()
.then(function() {
@@ -189,6 +190,7 @@ function init() {
adj(min, bbox, "y", "height")
}
editor.draw.viewbox(bbox)
+ editor.useGrid("imperial")
editor.updateGrid()
})