Skip to content

Commit 24227fd

Browse files
committed
fix(zoom): fit-branch includes sidebar cards in measurements
1 parent c3b5cbc commit 24227fd

2 files changed

Lines changed: 11 additions & 15 deletions

File tree

src/view/components/container/toolbar-vertical/helpers/fit-branch-into-view.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ export const fitBranchIntoView = async (view: LineageView) => {
1515
let result = 1;
1616

1717
const parents = Array.from(
18-
view.containerEl.querySelectorAll('.active-parent'),
18+
view.container.querySelectorAll('.active-parent'),
1919
) as HTMLElement[];
2020

21-
const activeNode = view.containerEl.querySelector(
21+
const activeNode = view.container.querySelector(
2222
'.active-node',
2323
) as HTMLElement;
2424
const children = Array.from(
25-
view.containerEl.querySelectorAll('.active-child'),
25+
view.container.querySelectorAll('.active-child'),
2626
) as HTMLElement[];
2727
const siblings = Array.from(
28-
view.containerEl.querySelectorAll('.active-sibling'),
28+
view.container.querySelectorAll('.active-sibling'),
2929
) as HTMLElement[];
3030

3131
const combinedRect = getCombinedBoundingClientRect([
@@ -35,12 +35,9 @@ export const fitBranchIntoView = async (view: LineageView) => {
3535
...children,
3636
]);
3737

38-
const heightScale =
39-
view.container.getBoundingClientRect().height /
40-
(combinedRect.height + 100);
41-
const widthScale =
42-
view.container.getBoundingClientRect().width /
43-
(combinedRect.width + 100);
38+
const boundingClientRect = view.container.getBoundingClientRect();
39+
const heightScale = boundingClientRect.height / (combinedRect.height + 100);
40+
const widthScale = boundingClientRect.width / (combinedRect.width + 100);
4441

4542
result = Math.min(heightScale, widthScale);
4643

src/view/components/container/toolbar-vertical/helpers/fit-document-height-into-view.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const fitDocumentHeightIntoView = async (view: LineageView) => {
1212
payload: { value: 1 },
1313
});
1414
const columns = Array.from(
15-
view.containerEl.querySelectorAll('.column'),
15+
view.container.querySelectorAll('.column'),
1616
) as HTMLElement[];
1717
let result = 1;
1818
if (columns.length) {
@@ -27,10 +27,9 @@ export const fitDocumentHeightIntoView = async (view: LineageView) => {
2727
const width = getCombinedBoundingClientRect(columns).width;
2828

2929
// eslint-disable-next-line no-undef
30-
const heightScale =
31-
view.container.getBoundingClientRect().height / (height + 100);
32-
const widthScale =
33-
view.container.getBoundingClientRect().width / (width + 100);
30+
const boundingClientRect = view.container.getBoundingClientRect();
31+
const heightScale = boundingClientRect.height / (height + 100);
32+
const widthScale = boundingClientRect.width / (width + 100);
3433

3534
result = Math.min(heightScale, widthScale);
3635
}

0 commit comments

Comments
 (0)