@@ -86,7 +86,22 @@ window.addEventListener('DOMContentLoaded', async () => {
8686 // Rows are separated by dx pixels, columns by dy pixels
8787 const root = d3 . hierarchy ( window . toctree ) ;
8888 const dx = 30 ; // Increased vertical spacing (was 20)
89- const dy = 200 ; // Increased horizontal spacing for better visibility
89+
90+ // Load column spacing from localStorage or use default
91+ let dy = parseInt ( localStorage . getItem ( 'toctree-column-spacing' ) ) || 200 ;
92+
93+ // Update the spacing display and slider
94+ const updateSpacingDisplay = ( ) => {
95+ const spacingValueEl = document . getElementById ( 'spacing-value' ) ;
96+ const spacingSlider = document . getElementById ( 'spacing-slider' ) ;
97+ if ( spacingValueEl ) {
98+ spacingValueEl . textContent = `${ dy } px` ;
99+ }
100+ if ( spacingSlider ) {
101+ spacingSlider . value = dy ;
102+ }
103+ } ;
104+ updateSpacingDisplay ( ) ;
90105
91106 // Define the tree layout and the shape for links
92107 const tree = d3 . tree ( ) . nodeSize ( [ dx , dy ] ) ;
@@ -307,6 +322,15 @@ window.addEventListener('DOMContentLoaded', async () => {
307322 update ( null , root ) ;
308323 } ) ;
309324
325+ // Column spacing slider control
326+ document . getElementById ( 'spacing-slider' ) ?. addEventListener ( 'input' , ( e ) => {
327+ dy = parseInt ( e . target . value ) ;
328+ localStorage . setItem ( 'toctree-column-spacing' , dy ) ;
329+ tree . nodeSize ( [ dx , dy ] ) ;
330+ updateSpacingDisplay ( ) ;
331+ update ( null , root ) ;
332+ } ) ;
333+
310334 // Search functionality
311335 const searchInput = document . getElementById ( 'search' ) ;
312336 if ( searchInput ) {
0 commit comments