@@ -74,6 +74,8 @@ class Topology extends Window {
7474
7575 this . dragging . element . x = x ;
7676 this . dragging . element . y = y ;
77+
78+ this . AdjustSvgSize ( ) ;
7779 } ;
7880
7981 this . content . onmouseup = ( ) => {
@@ -84,6 +86,10 @@ class Topology extends Window {
8486 this . stopButton . onclick = ( ) => this . Stop ( ) ;
8587 }
8688
89+ AfterResize ( ) { //override
90+ this . AdjustSvgSize ( ) ;
91+ }
92+
8793 InitializeSvg ( ) {
8894 this . svg = document . createElementNS ( "http://www.w3.org/2000/svg" , "svg" ) ;
8995 this . svg . setAttribute ( "width" , 1 ) ;
@@ -103,7 +109,7 @@ class Topology extends Window {
103109
104110 const loadingStop1 = document . createElementNS ( "http://www.w3.org/2000/svg" , "stop" ) ;
105111 loadingStop1 . setAttribute ( "offset" , ".15" ) ;
106- loadingStop1 . setAttribute ( "stop-color" , "#c0c0c080 " ) ;
112+ loadingStop1 . setAttribute ( "stop-color" , "#c0c0c060 " ) ;
107113 loadGradient . appendChild ( loadingStop1 ) ;
108114
109115 const loadingStop2 = document . createElementNS ( "http://www.w3.org/2000/svg" , "stop" ) ;
@@ -118,7 +124,7 @@ class Topology extends Window {
118124
119125 const loadingStop4 = document . createElementNS ( "http://www.w3.org/2000/svg" , "stop" ) ;
120126 loadingStop4 . setAttribute ( "offset" , ".85" ) ;
121- loadingStop4 . setAttribute ( "stop-color" , "#c0c0c080 " ) ;
127+ loadingStop4 . setAttribute ( "stop-color" , "#c0c0c060 " ) ;
122128 loadGradient . appendChild ( loadingStop4 ) ;
123129
124130 const animateTransform = document . createElementNS ( "http://www.w3.org/2000/svg" , "animateTransform" ) ;
@@ -386,7 +392,7 @@ class Topology extends Window {
386392
387393 const label = document . createElementNS ( "http://www.w3.org/2000/svg" , "text" ) ;
388394 label . innerHTML = options . name ;
389- label . setAttribute ( "y" , 104 ) ;
395+ label . setAttribute ( "y" , 106 ) ;
390396 label . setAttribute ( "x" , 48 ) ;
391397 label . setAttribute ( "font-size" , "11" ) ;
392398 label . setAttribute ( "font-weight" , "600" ) ;
@@ -408,8 +414,7 @@ class Topology extends Window {
408414 this . SelectDevice ( options . file ) ;
409415 } ) ;
410416
411- this . svg . setAttribute ( "width" , Math . max ( this . workspace . offsetWidth , options . x + 150 ) ) ;
412- this . svg . setAttribute ( "height" , Math . max ( this . workspace . offsetHeight , options . y + 150 ) ) ;
417+ this . AdjustSvgSize ( ) ;
413418
414419 return {
415420 root : g ,
@@ -458,4 +463,15 @@ class Topology extends Window {
458463 ipLabel . textContent = initial . ip ;
459464 grid . appendChild ( ipLabel ) ;
460465 }
466+
467+ AdjustSvgSize ( ) {
468+ let maxX = this . workspace . offsetWidth , maxY = this . workspace . offsetHeight ;
469+ for ( const file in this . devices ) {
470+ if ( this . devices [ file ] . element . x + 100 > maxX ) maxX = this . devices [ file ] . element . x + 100 ;
471+ if ( this . devices [ file ] . element . y + 128 > maxY ) maxY = this . devices [ file ] . element . y + 128 ;
472+ }
473+
474+ this . svg . setAttribute ( "width" , maxX === this . workspace . offsetWidth ? Math . max ( maxX - 20 , 1 ) : maxX ) ;
475+ this . svg . setAttribute ( "height" , maxY === this . workspace . offsetHeight ? Math . max ( maxY - 20 , 1 ) : maxY ) ;
476+ }
461477}
0 commit comments