@@ -9,7 +9,7 @@ var React = require('react/addons')
9
9
10
10
var Mindmap = React . createClass ( {
11
11
getDefaultProps : function ( ) {
12
- return { width : 800 , height : 800 }
12
+ return { width : 1200 , height : 800 }
13
13
} ,
14
14
15
15
mixins : [
@@ -60,7 +60,7 @@ var Mindmap = React.createClass({
60
60
this . props . store . actions . db . nodes ,
61
61
20 ,
62
62
100 ,
63
- 200 ,
63
+ 250 ,
64
64
this . state . heights ) ;
65
65
return positions
66
66
} ,
@@ -115,7 +115,7 @@ var Movable = React.createClass({
115
115
if ( ! pos ) return
116
116
var nx = this . state . left + pos . x
117
117
, ny = this . state . top + pos . y
118
- , margin = 100
118
+ , margin = 30
119
119
, dx = 0
120
120
, dy = 0
121
121
if ( nx - margin < 0 ) {
@@ -139,6 +139,31 @@ var Movable = React.createClass({
139
139
] ,
140
140
141
141
componentWillReceiveProps : function ( nextProps ) {
142
+ var aid = this . state . activeNode
143
+ , pos = nextProps . positions . boxes [ aid ]
144
+ if ( ! pos ) return
145
+ var nx = this . state . left + pos . x
146
+ , ny = this . state . top + pos . y
147
+ , margin = 30
148
+ , dx = 0
149
+ , dy = 0
150
+ if ( nx - margin < 0 ) {
151
+ dx -= nx - margin
152
+ }
153
+ if ( ny - margin < 0 ) {
154
+ dy -= ny - margin
155
+ }
156
+ if ( nx + pos . width + margin > this . props . width ) {
157
+ dx -= nx + pos . width + margin - this . props . width
158
+ }
159
+ if ( ny + pos . height + margin > this . props . height ) {
160
+ dy -= ny + pos . height + margin - this . props . height
161
+ }
162
+ this . setState ( {
163
+ left : this . state . left + dx ,
164
+ top : this . state . top + dy ,
165
+ } )
166
+ /*
142
167
var aid = this.props.store.view.active
143
168
, ppos = this.props.positions.boxes[aid]
144
169
, npos = nextProps.positions.boxes[aid]
@@ -157,6 +182,7 @@ var Movable = React.createClass({
157
182
left: this.state.left + dx,
158
183
top: this.state.top + dy,
159
184
})
185
+ */
160
186
} ,
161
187
162
188
componentDidUpdate : function ( prevProps , prevState ) {
0 commit comments