Skip to content

Commit 2f4012c

Browse files
committed
removed borders
1 parent 5e604c9 commit 2f4012c

File tree

2 files changed

+4
-100
lines changed

2 files changed

+4
-100
lines changed

media/explain/borderAndIconDraw.js

Lines changed: 2 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ export function deleteAllBorders() {
99
document.querySelectorAll(".border").forEach((el) => el.remove());
1010
}
1111

12-
function makeAllBordersTransparent() {
13-
document
14-
.querySelectorAll(".border")
15-
.forEach((el) => (el.style.borderColor = "transparent"));
16-
}
17-
1812
// @ts-ignore
1913
const iconMap = window.iconMap;
2014

@@ -35,67 +29,9 @@ function drawNodeIcon(fontSize, color, label) {
3529
return icon;
3630
}
3731

38-
function isOverlappingWithTopRightCorner(bordersTopRightPosition, topLeft) {
39-
const marginOfError = 8;
40-
return bordersTopRightPosition.some(([x, y]) => {
41-
if (y === topLeft.y) {
42-
return x + marginOfError >= topLeft.x;
43-
}
44-
});
45-
}
46-
47-
function isEnoughAreaForBorders(
48-
cy,
49-
paddingX,
50-
paddingY,
51-
iconSize,
52-
iconGap,
53-
windowPadding
54-
) {
55-
const windowWidth = window.innerWidth;
56-
const windowHeight = window.innerHeight;
57-
58-
let areaNeededForAllNodes = 0;
59-
let maxHeightNeededForBorder = 0;
60-
let maxWidthNeededForBorder = 0;
61-
62-
cy.nodes().forEach((node) => {
63-
const nodeW = node.renderedWidth();
64-
const nodeH = node.renderedHeight();
65-
const dimensions = getBorderWidthAndHeight(
66-
paddingX,
67-
nodeW,
68-
paddingY,
69-
nodeH,
70-
iconSize,
71-
iconGap
72-
);
73-
areaNeededForAllNodes += dimensions.width * dimensions.height;
74-
maxHeightNeededForBorder = Math.max(
75-
maxHeightNeededForBorder,
76-
dimensions.height
77-
);
78-
maxWidthNeededForBorder = Math.max(
79-
maxWidthNeededForBorder,
80-
dimensions.width
81-
);
82-
});
83-
84-
const usableWidth = windowWidth - 2 * windowPadding;
85-
const usableHeight = windowHeight - 2 * windowPadding;
86-
87-
const maxCols = Math.floor(usableWidth / maxWidthNeededForBorder);
88-
const maxRows = Math.floor(usableHeight / maxHeightNeededForBorder);
89-
90-
const maxNodesThatCanFit = maxCols * maxRows;
91-
92-
return cy.nodes().length <= maxNodesThatCanFit;
93-
}
94-
9532
export function drawBorderAndIconForEachExplainNode(
9633
cy,
97-
windowPadding,
98-
isVisible
34+
windowPadding
9935
) {
10036
const paddingX = 30;
10137
const paddingY = 10;
@@ -110,15 +46,6 @@ export function drawBorderAndIconForEachExplainNode(
11046
minIconSize = Math.min(minIconSize, iconSize);
11147
});
11248

113-
let shouldDrawBorders = isEnoughAreaForBorders(
114-
cy,
115-
paddingX,
116-
paddingY,
117-
minIconSize,
118-
iconGap,
119-
windowPadding
120-
);
121-
const bordersTopRightPosition = [];
12249

12350
cy.nodes().forEach((node) => {
12451
const nodeW = node.renderedWidth();
@@ -156,22 +83,9 @@ export function drawBorderAndIconForEachExplainNode(
15683
justifyContent: "center",
15784
paddingTop: `${paddingY}px`,
15885
borderRadius: `${borderRadius}px`,
86+
borderColor: "transparent"
15987
});
16088

161-
const overlappingWithTopRightCorner = isOverlappingWithTopRightCorner(
162-
bordersTopRightPosition,
163-
topLeft
164-
);
165-
if (overlappingWithTopRightCorner) {
166-
shouldDrawBorders = false;
167-
makeAllBordersTransparent();
168-
}
169-
bordersTopRightPosition.push([topLeft.x + dimensions.width, topLeft.y]);
170-
171-
if (!shouldDrawBorders || !isVisible) {
172-
border.style.borderColor = "transparent";
173-
}
174-
17589
border.appendChild(drawNodeIcon(minIconSize, iconColor, node.data().label));
17690
document.body.appendChild(border);
17791
});

media/explain/explain.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,22 +153,12 @@ if (isWindowTooSmall(GRAPH_PADDING)) {
153153
});
154154
});
155155

156-
function isVisibleBorders() {
157-
console.log(window.location.href);
158-
const border = document.querySelector(".border");
159-
if (border !== null) {
160-
return border.style.borderColor !== "transparent";
161-
}
162-
return false;
163-
}
164-
165156
function redrawBorders() {
166-
const showBorder = isVisibleBorders();
167157
deleteAllBorders();
168-
drawBorderAndIconForEachExplainNode(cy, GRAPH_PADDING, showBorder);
158+
drawBorderAndIconForEachExplainNode(cy, GRAPH_PADDING);
169159
}
170160

171161
cy.on("pan zoom resize", redrawBorders);
172-
drawBorderAndIconForEachExplainNode(cy, GRAPH_PADDING, true);
162+
drawBorderAndIconForEachExplainNode(cy, GRAPH_PADDING);
173163
}
174164
}

0 commit comments

Comments
 (0)