File tree 1 file changed +20
-0
lines changed
scala3doc/resources/dotty_res/scripts
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,26 @@ function showGraph() {
85
85
} ) ;
86
86
} ) ;
87
87
render ( inner , g ) ;
88
+
89
+ // Set the 'fit to content graph' upon landing on the page
90
+
91
+ var bounds = svg . node ( ) . getBBox ( ) ;
92
+ var parent = svg . node ( ) . parentElement ;
93
+ var fullWidth = parent . clientWidth || parent . parentNode . clientWidth ,
94
+ fullHeight = parent . clientHeight || parent . parentNode . clientHeight ;
95
+ var width = bounds . width ,
96
+ height = bounds . height ;
97
+ var midX = bounds . x + width / 2 ,
98
+ midY = bounds . y + height / 2 ;
99
+ if ( width == 0 || height == 0 ) return ; // nothing to fit
100
+ var scale = 0.85 / Math . max ( width / fullWidth , height / fullHeight ) ;
101
+ var translate = [ fullWidth / 2 - scale * midX , fullHeight / 2 - scale * midY ] ;
102
+
103
+ var transform = d3 . zoomIdentity
104
+ . translate ( translate [ 0 ] , translate [ 1 ] )
105
+ . scale ( scale ) ;
106
+
107
+ svg . call ( zoom . transform , transform ) ;
88
108
}
89
109
}
90
110
}
You can’t perform that action at this time.
0 commit comments