8
8
:key =" componentData.componentName"
9
9
:id =" componentData.componentName"
10
10
:x =" componentData.x"
11
- :y =" componentData.y + 20 "
11
+ :y =" componentData.y"
12
12
:z =" componentData.z"
13
13
:w =" componentData.w"
14
14
:h =" componentData.h"
19
19
@dragging =" onDrag"
20
20
@resizing =" onResize"
21
21
@dblclick.native =" onDoubleClick(componentData)"
22
+ @dragstop =" finishedDrag"
23
+ @resizestop =" finishedResize"
24
+ :onDragStart =" recordInitialPosition"
25
+ :onResizeStart =" recordInitialSize"
22
26
>
27
+ <!-- :onDragStart="recordInitialPosition"
28
+ :onResizeStart="recordInitialSize" -->
23
29
<div class =" component-title" >
24
30
<p >{{ componentData.componentName }}</p >
25
31
</div >
@@ -85,7 +91,9 @@ export default {
85
91
testOptions: [" parent" , " child" , " grandchild" ],
86
92
testModel: [],
87
93
mockImg: false ,
88
- counter: 0
94
+ counter: 0 ,
95
+ initialPosition: {x: 0 , y: 0 ,},
96
+ initialSize: {w: 0 ,h: 0 ,},
89
97
};
90
98
},
91
99
mounted () {
@@ -176,33 +184,40 @@ export default {
176
184
},
177
185
178
186
updated () {
179
- console .log (" updated" )
187
+ // console.log("updated")
180
188
if (this .activeComponent === ' ' )
181
189
{
190
+ if (this .$refs .boxes ){
182
191
this .$refs .boxes .forEach ((element )=> {
183
192
element .enabled = false ;
184
193
element .$emit (' deactivated' )
185
194
element .$emit (' update:active' , false )
186
195
187
- })
196
+ })}
188
197
}
189
198
else {
190
- this .$refs .boxes .forEach ((element )=> {
191
- if (this .activeComponent === element .$attrs .id )
192
- {
193
- element .enabled = true
194
- element .$emit (' activated' )
195
- element .$emit (' update:active' , true )
196
- }
197
- })
198
- }
199
- },
199
+ this .$refs .boxes .forEach ((element )=> {
200
+ // added "element.enabled === false to stop it from emitting a change every frame the box moves
201
+ // may need to re-enable to track box movement and resizing since that stuff isn't part of a single source of truth.
202
+ if (this .activeComponent === element .$attrs .id && element .enabled === false )
203
+ {
204
+ element .enabled = true
205
+ element .$emit (' activated' )
206
+ element .$emit (' update:active' , true )
207
+ }
208
+ })
209
+ }
210
+ },
200
211
201
212
methods: {
202
213
... mapActions ([
203
214
" setActiveComponent" ,
204
215
" updateComponentChildrenMultiselectValue" ,
205
- " updateActiveComponentChildrenValue"
216
+ " updateActiveComponentChildrenValue" ,
217
+ " updateComponentPosition" ,
218
+ " updateStartingPosition" ,
219
+ " updateStartingSize" ,
220
+ " updateComponentSize" ,
206
221
]),
207
222
onResize : function (x , y , width , height ) {
208
223
this .activeComponentData .x = x;
@@ -215,6 +230,71 @@ export default {
215
230
this .componentMap [this .activeComponent ].w = width;
216
231
this .componentMap [this .activeComponent ].h = height;
217
232
},
233
+
234
+ recordInitialPosition : function (e ) {
235
+ console .log (" we started a drag" )
236
+ console .log (" this.intialPosition" ,this .initialPosition )
237
+ console .log (" WHAT IS THIS" , this )
238
+ if (this .activeComponent !== e .target .id ){
239
+ this .setActiveComponent (e .target .id )
240
+ }
241
+ this .initialPosition .x = this .activeComponentData .x
242
+ this .initialPosition .y = this .activeComponentData .y
243
+ // console.log(this.activeComponentData)
244
+ // console.log(this.activeComponentData.x)
245
+ // console.log(this.initialPosition.x)
246
+ // console.log(this.initialPosition.y)
247
+
248
+ let payload = {
249
+ x: this .initialPosition .x ,
250
+ y: this .initialPosition .y ,
251
+ activeComponent: this .activeComponent ,
252
+ routeArray: this .routes [this .activeRoute ],
253
+ activeComponentData: this .activeComponentData
254
+ }
255
+ console .log (" x: " ,payload .x ," y: " ,payload .y )
256
+ // this.updateStartingPosition(payload);
257
+ },
258
+
259
+ recordInitialSize : function (e ){
260
+ console .log (" MAKE MY MONSTER GROW!" )
261
+
262
+ this .initialSize .h = this .activeComponentData .h
263
+ this .initialSize .w = this .activeComponentData .w
264
+ this .initialPosition .x = this .activeComponentData .x
265
+ this .initialPosition .y = this .activeComponentData .y
266
+
267
+ let payload = {
268
+ h: this .initialSize .h ,
269
+ w: this .initialSize .w ,
270
+ x: this .activeComponentData .x ,
271
+ y: this .activeComponentData .y ,
272
+ activeComponent: this .activeComponent ,
273
+ routeArray: this .routes [this .activeRoute ],
274
+ activeComponentData: this .activeComponentData
275
+ }
276
+
277
+ // this.updateStartingSize(payload);
278
+
279
+ },
280
+
281
+ finishedResize : function (x ,y ,w ,h ){
282
+ console .log (" FINISHED RESIZING" )
283
+ let payload = {
284
+ x: x,
285
+ y: y,
286
+ w: w,
287
+ h: h,
288
+ activeComponent: this .activeComponent ,
289
+ routeArray: this .routes [this .activeRoute ],
290
+ activeComponentData: this .activeComponentData
291
+ }
292
+ if (payload .x !== this .initialPosition .x || payload .y !== this .initialPosition .y ||
293
+ payload .w !== this .initialSize .w || payload .h !== this .initialSize .h ){
294
+ this .updateComponentSize (payload)
295
+ }
296
+ },
297
+
218
298
onDrag : function (x , y ) {
219
299
this .activeComponentData .x = x;
220
300
this .activeComponentData .y = y;
@@ -223,19 +303,45 @@ export default {
223
303
this .componentMap [this .activeComponent ].y = y;
224
304
this .userImage ;
225
305
},
226
- onLayer : function (z ) {
227
- this .activeComponentData .z = z;
306
+ // onLayer: function(z) {
307
+ // this.activeComponentData.z = z;
308
+ // // Want to change the "Z" of the component found in Routes[activeRoute][whatever the component is]
309
+ // //have to do this via an action or it won't be preserved in our undo/redo
310
+ // },
311
+
312
+ finishedDrag : function (x ,y ){
313
+ console .log (" FINISHED DRAGGING" )
314
+ let payload = {
315
+ x: x,
316
+ y: y,
317
+ activeComponent: this .activeComponent ,
318
+ routeArray: this .routes [this .activeRoute ],
319
+ activeComponentData: this .activeComponentData
320
+ }
321
+ // console.log("Payload.x = ", payload.x, "this.initialPosition.x", this.initialPosition.x)
322
+ // console.log("Payload.y = ", payload.y, "this.initialPosition.y", this.initialPosition.y)
323
+ if (payload .x !== this .initialPosition .x || payload .y !== this .initialPosition .y ){
324
+ this .updateComponentPosition (payload);
325
+ }
228
326
},
327
+
229
328
onActivated (componentData ) {
329
+ // console.log("I RAN!")
230
330
this .$refs .boxes .forEach ((element )=> {
231
331
if (element .$attrs .id !== componentData .componentName ){
232
332
element .enabled = false ;
233
333
element .$emit (' deactivated' )
234
334
element .$emit (' update:active' , false )
235
335
}
236
336
})
237
- this .setActiveComponent (componentData .componentName );
337
+ // console.log("this is what is currently active",this.activeComponent)
338
+ // console.log("this is this", this)
339
+ // console.log('!(componentData.componentName === this.activeComponent)?',!(componentData.componentName === this.activeComponent))
340
+ if (! (componentData .componentName === this .activeComponent )){
341
+ this .setActiveComponent (componentData .componentName );
342
+ }
238
343
this .activeComponentData .isActive = true ;
344
+
239
345
240
346
},
241
347
@@ -253,7 +359,9 @@ export default {
253
359
// }
254
360
},
255
361
onDoubleClick (compData ) {
256
- this .setActiveComponent (compData .componentName );
362
+ if (! (componentData .componentName === this .activeComponent )){
363
+ this .setActiveComponent (componentData .componentName );
364
+ }
257
365
this .activeComponentData .isActive = true ;
258
366
},
259
367
handleAddChild () {
@@ -291,7 +399,9 @@ export default {
291
399
handleClick (event ){
292
400
if (event .target .className === " component-display grid-bg" )
293
401
{
294
- this .setActiveComponent (' ' )
402
+ if (! (' ' === this .activeComponent )){
403
+ this .setActiveComponent (' ' );
404
+ }
295
405
}
296
406
}
297
407
}
@@ -310,7 +420,7 @@ export default {
310
420
/* width: 1rem; */
311
421
line-height : 1.2 ;
312
422
/* margin: 10px; */
313
- z-index : 0 ;
423
+ z-index : -1 ;
314
424
}
315
425
.component-children {
316
426
position : absolute ;
0 commit comments