@@ -36,9 +36,7 @@ class Rectangle extends Component<PropsInt, StateInt> {
36
36
} ;
37
37
38
38
getComponentColor ( componentId : number ) {
39
- const color = this . props . components . find (
40
- ( comp : ComponentInt ) => comp . id === componentId
41
- ) . color ;
39
+ const color = this . props . components . find ( ( comp : ComponentInt ) => comp . id === componentId ) . color ;
42
40
return color ;
43
41
}
44
42
@@ -48,12 +46,7 @@ class Rectangle extends Component<PropsInt, StateInt> {
48
46
) ;
49
47
}
50
48
51
- handleResize (
52
- componentId : number ,
53
- childId : number ,
54
- target : any ,
55
- blockSnapSize : number
56
- ) {
49
+ handleResize ( componentId : number , childId : number , target : any , blockSnapSize : number ) {
57
50
let focChild : ChildInt = this . props . components
58
51
. find ( ( comp : ComponentInt ) => comp . id === this . props . componentId )
59
52
. childrenArray . find ( ( child : ChildInt ) => child . childId === childId ) ;
@@ -64,24 +57,15 @@ class Rectangle extends Component<PropsInt, StateInt> {
64
57
) ;
65
58
}
66
59
const transformation = {
67
- width :
68
- Math . round ( ( target . width ( ) * target . scaleX ( ) ) / blockSnapSize ) *
69
- blockSnapSize ,
70
- height :
71
- Math . round ( ( target . height ( ) * target . scaleY ( ) ) / blockSnapSize ) *
72
- blockSnapSize ,
60
+ width : Math . round ( ( target . width ( ) * target . scaleX ( ) ) / blockSnapSize ) * blockSnapSize ,
61
+ height : Math . round ( ( target . height ( ) * target . scaleY ( ) ) / blockSnapSize ) * blockSnapSize ,
73
62
x : target . x ( ) + focChild . position . x ,
74
63
y : target . y ( ) + focChild . position . y
75
64
} ;
76
65
this . props . handleTransform ( componentId , childId , transformation ) ;
77
66
}
78
67
79
- handleDrag (
80
- componentId : number ,
81
- childId : number ,
82
- target : any ,
83
- blockSnapSize : any
84
- ) {
68
+ handleDrag ( componentId : number , childId : number , target : any , blockSnapSize : any ) {
85
69
const transformation = {
86
70
x : Math . round ( target . x ( ) / blockSnapSize ) * blockSnapSize ,
87
71
y : Math . round ( target . y ( ) / blockSnapSize ) * blockSnapSize
@@ -129,20 +113,18 @@ class Rectangle extends Component<PropsInt, StateInt> {
129
113
scaleY = { scaleY }
130
114
width = { width }
131
115
height = { height }
132
- onDragEnd = { event =>
133
- this . handleDrag ( componentId , childId , event . target , blockSnapSize )
134
- }
116
+ onDragEnd = { event => this . handleDrag ( componentId , childId , event . target , blockSnapSize ) }
135
117
ref = { node => {
136
118
this . group = node ;
137
119
} }
138
- tabIndex = '0' // required for keypress event to be heard by this.group
120
+ tabIndex = "0" // required for keypress event to be heard by this.group
139
121
>
140
122
< Rect
141
123
// a Konva Rect is generated for each child of the focusComponent (including the pseudochild, representing the focusComponent itself)
142
124
ref = { node => {
143
125
this . rect = node ;
144
126
} }
145
- tabIndex = '0' // required for keypress event to be heard by this.group
127
+ tabIndex = "0" // required for keypress event to be heard by this.group
146
128
name = { `${ childId } ` }
147
129
className = { 'childRect' }
148
130
x = { 0 }
@@ -154,11 +136,7 @@ class Rectangle extends Component<PropsInt, StateInt> {
154
136
scaleY = { 1 }
155
137
width = { width }
156
138
height = { height }
157
- stroke = {
158
- childType === 'COMP'
159
- ? this . getComponentColor ( childComponentId )
160
- : '#000000'
161
- }
139
+ stroke = { childType === 'COMP' ? this . getComponentColor ( childComponentId ) : '#000000' }
162
140
onTransformEnd = { event =>
163
141
this . handleResize ( componentId , childId , event . target , blockSnapSize )
164
142
}
@@ -167,11 +145,9 @@ class Rectangle extends Component<PropsInt, StateInt> {
167
145
draggable = { false }
168
146
fill = { null }
169
147
shadowBlur = { childId === - 1 ? 6 : null }
170
-
171
148
fillPatternImage = { this . state . image ? this . state . image : null }
172
149
fillPatternScaleX = { this . state . image ? width / this . state . image . width : 1 }
173
150
fillPatternScaleY = { this . state . image ? height / this . state . image . height : 1 }
174
-
175
151
_useStrictMode
176
152
/>
177
153
< Label >
@@ -180,11 +156,7 @@ class Rectangle extends Component<PropsInt, StateInt> {
180
156
fontVariant = { 'small-caps' }
181
157
// pseudochild's label should look different than normal children:
182
158
text = { childId === - 1 ? title . slice ( 0 , title . length - 2 ) : title }
183
- fill = {
184
- childId === - 1
185
- ? this . getComponentColor ( childComponentId )
186
- : '#000000'
187
- }
159
+ fill = { childId === - 1 ? this . getComponentColor ( childComponentId ) : '#000000' }
188
160
fontSize = { childId === - 1 ? 15 : 10 }
189
161
x = { 4 }
190
162
y = { childId === - 1 ? - 20 : - 12 }
@@ -203,20 +175,14 @@ class Rectangle extends Component<PropsInt, StateInt> {
203
175
componentId = { componentId }
204
176
directParentName = { childComponentName }
205
177
childType = { grandchild . childType }
206
- imageSource = {
207
- grandchild . htmlElement === 'Image' && grandchild . HTMLInfo . Src
208
- }
178
+ imageSource = { grandchild . htmlElement === 'Image' && grandchild . HTMLInfo . Src }
209
179
childComponentName = { grandchild . componentName }
210
180
childComponentId = { grandchild . childComponentId }
211
181
focusChild = { focusChild }
212
182
childId = { childId } // scary addition, grandchildren rects default to childId of "direct" children
213
- width = {
214
- grandchild . position . width *
215
- ( width / this . getPseudoChild ( ) . position . width )
216
- }
183
+ width = { grandchild . position . width * ( width / this . getPseudoChild ( ) . position . width ) }
217
184
height = {
218
- grandchild . position . height *
219
- ( height / this . getPseudoChild ( ) . position . height )
185
+ grandchild . position . height * ( height / this . getPseudoChild ( ) . position . height )
220
186
}
221
187
x = {
222
188
( grandchild . position . x - this . getPseudoChild ( ) . position . x ) *
0 commit comments