mirror of
https://github.com/Matysh/houseplan-card
synced 2026-07-31 08:28:31 +00:00
zoom-out, device-aware content frame, and the editor no longer shifts the plan
Three owner reports: - The content frame behind the default zoom only looked at rooms, and devices are allowed to stand outside every one of them — a gate sensor by the fence was left outside the opening view. contentBounds() takes the marker positions now, and they count as content even on a space with no rooms at all. - Entering an editor 'strangely shifted' the plan. The stage height was 100dvh minus a hard-coded 118px of header, and the editor header is ~90px taller than that: the whole scene slid down by the difference and its bottom went below the fold. The card now measures where the stage actually starts (HA toolbar, margins and our header included) and gives it the rest of the viewport; the measurement is deferred a frame because setting state straight from a ResizeObserver callback trips the 'undelivered notifications' error, which smoke_dialog_zombie rightly counts as a page error. - Zoom stopped at the base fit. The floor is 0.4× now, and zoomed out the clamp centres the content instead of pinning it to the top-left corner — with the view larger than the plan there is nothing to clamp against. New smoke: smoke_zoom_out.mjs (editor keeps the stage inside the viewport, 0.4 floor, centring, the device-stretched frame); a unit test for the extra points of contentBounds. Not released — the next release goes out after the v1.49.0 audit.
This commit is contained in:
@@ -106,3 +106,20 @@ test('contentBounds: fits what is drawn, with a 5% margin', () => {
|
||||
const empty = spaceModels({ spaces: [{ id: 's', view_box: [0, 0, 1, 1], rooms: [] }], markers: [] })[0];
|
||||
assert.equal(contentBounds(empty), null);
|
||||
});
|
||||
|
||||
test('contentBounds: devices outside every room stretch the frame', () => {
|
||||
const one = spaceModels({ spaces: [{
|
||||
id: 's', view_box: [0, 0, 1, 1],
|
||||
rooms: [{ id: 'r', poly: [[0.4, 0.4], [0.6, 0.4], [0.6, 0.6], [0.4, 0.6]] }],
|
||||
}], markers: [] })[0];
|
||||
// a gate sensor far to the right of the room
|
||||
const b = contentBounds(one, 0.05, [[900, 500]]);
|
||||
// span 400..900 wide, 400..600 tall; margin 5% of the larger side (500)
|
||||
assert.deepEqual(b, { x: 375, y: 375, w: 550, h: 250 });
|
||||
// devices alone are content enough — an empty yard with two cameras
|
||||
const empty = spaceModels({ spaces: [{ id: 's', view_box: [0, 0, 1, 1], rooms: [] }], markers: [] })[0];
|
||||
const only = contentBounds(empty, 0.05, [[100, 100], [300, 200]]);
|
||||
assert.equal(Math.round(only.w), 220);
|
||||
// and junk coordinates are ignored, not spread across the canvas
|
||||
assert.deepEqual(contentBounds(one, 0.05, [[NaN, 5]]), contentBounds(one));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user