@@ -81,6 +81,7 @@ class App extends Component {
81
81
data : orgChartJson ,
82
82
totalNodeCount : countNodes ( 0 , Array . isArray ( orgChartJson ) ? orgChartJson [ 0 ] : orgChartJson ) ,
83
83
orientation : 'horizontal' ,
84
+ dimensions : undefined ,
84
85
translateX : 200 ,
85
86
translateY : 300 ,
86
87
collapsible : true ,
@@ -94,7 +95,6 @@ class App extends Component {
94
95
nodeSize : { x : 200 , y : 200 } ,
95
96
enableLegacyTransitions : false ,
96
97
transitionDuration : 500 ,
97
- dimensions : undefined ,
98
98
renderCustomNodeElement : customNodeFnMapping [ 'svg' ] . fn ,
99
99
styles : {
100
100
nodes : {
@@ -209,11 +209,11 @@ class App extends Component {
209
209
} ) ;
210
210
} else {
211
211
if ( this . treeContainer ) {
212
- const dimensions = this . treeContainer . getBoundingClientRect ( ) ;
212
+ const { width , height } = this . treeContainer . getBoundingClientRect ( ) ;
213
213
this . setState ( {
214
214
dimensions : {
215
- width : dimensions . width ,
216
- height : dimensions . height ,
215
+ width,
216
+ height,
217
217
} ,
218
218
} ) ;
219
219
}
@@ -414,7 +414,9 @@ class App extends Component {
414
414
</ div >
415
415
416
416
< 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 >
418
420
< Switch
419
421
name = "centerNodesBtn"
420
422
checked = { this . state . dimensions !== undefined }
@@ -640,6 +642,7 @@ class App extends Component {
640
642
rootNodeClassName = "demo-node"
641
643
branchNodeClassName = "demo-node"
642
644
orientation = { this . state . orientation }
645
+ dimensions = { this . state . dimensions }
643
646
translate = { { x : this . state . translateX , y : this . state . translateY } }
644
647
pathFunc = { this . state . pathFunc }
645
648
collapsible = { this . state . collapsible }
@@ -674,7 +677,6 @@ class App extends Component {
674
677
onLinkMouseOut = { ( ...args ) => {
675
678
console . log ( 'onLinkMouseOut' , args ) ;
676
679
} }
677
- dimensions = { this . state . dimensions }
678
680
/>
679
681
</ div >
680
682
</ div >
0 commit comments