@@ -6,22 +6,35 @@ import TransformerComponent from './TransformerComponent.jsx';
6
6
// import PropTypes from 'prop-types';
7
7
8
8
class Rectangle extends Component {
9
- handleResize ( componentId , childId , target ) {
9
+ handleResize ( componentId , childId , target , components ) {
10
+ const focChild = components
11
+ . find ( comp => comp . id === componentId )
12
+ . childrenArray . find ( child => child . childId === childId ) ;
13
+
10
14
const transformation = {
11
15
width : target . width ( ) * target . scaleX ( ) ,
12
16
height : target . height ( ) * target . scaleY ( ) ,
17
+ x : target . x ( ) + focChild . position . x ,
18
+ y : target . y ( ) + focChild . position . y ,
13
19
} ;
20
+
14
21
this . props . handleTransform ( componentId , childId , transformation ) ;
15
22
}
16
23
17
24
handleDrag ( componentId , childId , target ) {
25
+ console . log ( target ) ;
26
+
18
27
const transformation = {
19
28
x : target . x ( ) ,
20
29
y : target . y ( ) ,
21
30
} ;
22
31
this . props . handleTransform ( componentId , childId , transformation ) ;
23
32
}
24
33
34
+ findDescendants ( component ) {
35
+
36
+ }
37
+
25
38
render ( ) {
26
39
const {
27
40
color,
@@ -35,6 +48,7 @@ class Rectangle extends Component {
35
48
title,
36
49
focusChild,
37
50
focusComponent,
51
+ components,
38
52
} = this . props ;
39
53
40
54
// the Group is responsible for dragging of all children
@@ -52,8 +66,9 @@ class Rectangle extends Component {
52
66
>
53
67
< Rect
54
68
name = { `${ childId } ` }
55
- // x={0}
56
- // y={0}
69
+ x = { 0 }
70
+ y = { 0 }
71
+ // absolutePosition={{ x, y }}
57
72
childId = { childId }
58
73
componentId = { componentId }
59
74
title = { title }
@@ -65,14 +80,16 @@ class Rectangle extends Component {
65
80
color = { color }
66
81
// fill={color}
67
82
// opacity={0.8}
68
- onTransformEnd = { event => this . handleResize ( componentId , childId , event . target ) }
83
+ onTransformEnd = { event => this . handleResize ( componentId , childId , event . target , components )
84
+ }
69
85
strokeWidth = { 4 }
70
86
strokeScaleEnabled = { false }
71
87
draggable = { false }
72
88
/>
73
89
< Label >
74
90
< Text text = { title } fill = { 'white' } />
75
91
</ Label >
92
+ { }
76
93
< Rect
77
94
// replace with grandchildren rectangles
78
95
scaleX = { 0.2 }
0 commit comments