@@ -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
1913const 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-
9532export 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 } ) ;
0 commit comments