@@ -81,6 +81,7 @@ class App extends Component {
8181 data : orgChartJson ,
8282 totalNodeCount : countNodes ( 0 , Array . isArray ( orgChartJson ) ? orgChartJson [ 0 ] : orgChartJson ) ,
8383 orientation : 'horizontal' ,
84+ dimensions : undefined ,
8485 translateX : 200 ,
8586 translateY : 300 ,
8687 collapsible : true ,
@@ -94,7 +95,6 @@ class App extends Component {
9495 nodeSize : { x : 200 , y : 200 } ,
9596 enableLegacyTransitions : false ,
9697 transitionDuration : 500 ,
97- dimensions : undefined ,
9898 renderCustomNodeElement : customNodeFnMapping [ 'svg' ] . fn ,
9999 styles : {
100100 nodes : {
@@ -209,11 +209,11 @@ class App extends Component {
209209 } ) ;
210210 } else {
211211 if ( this . treeContainer ) {
212- const dimensions = this . treeContainer . getBoundingClientRect ( ) ;
212+ const { width , height } = this . treeContainer . getBoundingClientRect ( ) ;
213213 this . setState ( {
214214 dimensions : {
215- width : dimensions . width ,
216- height : dimensions . height ,
215+ width,
216+ height,
217217 } ,
218218 } ) ;
219219 }
@@ -414,7 +414,9 @@ class App extends Component {
414414 </ div >
415415
416416 < div className = "prop-container" >
417- < h4 className = "prop" > Center Nodes on Click</ h4 >
417+ < h4 className = "prop" >
418+ Center Nodes on Click (via < code > dimensions</ code > prop)
419+ </ h4 >
418420 < Switch
419421 name = "centerNodesBtn"
420422 checked = { this . state . dimensions !== undefined }
@@ -640,6 +642,7 @@ class App extends Component {
640642 rootNodeClassName = "demo-node"
641643 branchNodeClassName = "demo-node"
642644 orientation = { this . state . orientation }
645+ dimensions = { this . state . dimensions }
643646 translate = { { x : this . state . translateX , y : this . state . translateY } }
644647 pathFunc = { this . state . pathFunc }
645648 collapsible = { this . state . collapsible }
@@ -674,7 +677,6 @@ class App extends Component {
674677 onLinkMouseOut = { ( ...args ) => {
675678 console . log ( 'onLinkMouseOut' , args ) ;
676679 } }
677- dimensions = { this . state . dimensions }
678680 />
679681 </ div >
680682 </ div >
0 commit comments