@@ -42,12 +42,17 @@ export default class Node extends React.Component {
42
42
return transform ;
43
43
}
44
44
45
- applyTransform ( transform , done ) {
46
- select ( this . node )
47
- . transition ( )
48
- . duration ( 500 )
49
- . attr ( 'transform' , transform )
50
- . each ( 'end' , done ) ;
45
+ applyTransform ( transform , done = ( ) => { } ) {
46
+ const { enabled, duration } = this . props . transitions ;
47
+ if ( enabled ) {
48
+ select ( this . node )
49
+ . transition ( )
50
+ . duration ( duration )
51
+ . attr ( 'transform' , transform )
52
+ . each ( 'end' , done ) ;
53
+ } else {
54
+ done ( ) ;
55
+ }
51
56
}
52
57
53
58
componentWillLeave ( done ) {
@@ -64,7 +69,11 @@ export default class Node extends React.Component {
64
69
}
65
70
66
71
render ( ) {
67
- const { nodeData, depthFactor } = this . props ;
72
+ const { nodeData, depthFactor, transitions } = this . props ;
73
+ const transform = transitions . enabled ?
74
+ this . state . transform :
75
+ this . setTransformOrientation ( nodeData . x , nodeData . y ) ;
76
+
68
77
69
78
if ( depthFactor ) {
70
79
nodeData . y = nodeData . depth * depthFactor ;
@@ -74,7 +83,7 @@ export default class Node extends React.Component {
74
83
id = { nodeData . id }
75
84
ref = { ( n ) => { this . node = n ; } }
76
85
className = { nodeData . _children ? 'nodeBase' : 'leafNodeBase' }
77
- transform = { this . state . transform }
86
+ transform = { transform }
78
87
onClick = { this . handleClick }
79
88
>
80
89
< text
@@ -111,6 +120,7 @@ export default class Node extends React.Component {
111
120
}
112
121
113
122
Node . defaultProps = {
123
+ depthFactor : undefined ,
114
124
circleRadius : 10 ,
115
125
circleStyle : {
116
126
stroke : '#000' ,
@@ -124,14 +134,15 @@ Node.defaultProps = {
124
134
} ,
125
135
} ;
126
136
127
- /* eslint-disable*/
137
+ /* eslint-disable */
128
138
Node . propTypes = {
129
139
nodeData : PropTypes . object . isRequired ,
130
140
orientation : PropTypes . oneOf ( [
131
141
'horizontal' ,
132
142
'vertical' ,
133
143
] ) . isRequired ,
134
- onClick : PropTypes . func ,
144
+ transitions : PropTypes . object . isRequired ,
145
+ onClick : PropTypes . func . isRequired ,
135
146
depthFactor : PropTypes . number ,
136
147
primaryLabel : PropTypes . string ,
137
148
primaryLabelStyle : PropTypes . object ,
0 commit comments