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,32 +184,47 @@ 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 )=> {
192
+ <<<<<< < HEAD
183
193
element .enabled = false ;
184
194
element .$emit (' deactivated' )
185
195
element .$emit (' update:active' , false )
186
196
})
197
+ ====== =
198
+ element .enabled = false ;
199
+ element .$emit (' deactivated' )
200
+ element .$emit (' update:active' , false )
201
+
202
+ })}
203
+ >>>>>> > master
187
204
}
188
205
else {
189
- this .$refs .boxes .forEach ((element )=> {
190
- if (this .activeComponent === element .$attrs .id )
191
- {
192
- element .enabled = true
193
- element .$emit (' activated' )
194
- element .$emit (' update:active' , true )
195
- }
196
- })
197
- }
198
- },
206
+ this .$refs .boxes .forEach ((element )=> {
207
+ // added "element.enabled === false to stop it from emitting a change every frame the box moves
208
+ // may need to re-enable to track box movement and resizing since that stuff isn't part of a single source of truth.
209
+ if (this .activeComponent === element .$attrs .id && element .enabled === false )
210
+ {
211
+ element .enabled = true
212
+ element .$emit (' activated' )
213
+ element .$emit (' update:active' , true )
214
+ }
215
+ })
216
+ }
217
+ },
199
218
200
219
methods: {
201
220
... mapActions ([
202
221
" setActiveComponent" ,
203
222
" updateComponentChildrenMultiselectValue" ,
204
- " updateActiveComponentChildrenValue"
223
+ " updateActiveComponentChildrenValue" ,
224
+ " updateComponentPosition" ,
225
+ " updateStartingPosition" ,
226
+ " updateStartingSize" ,
227
+ " updateComponentSize" ,
205
228
]),
206
229
onResize : function (x , y , width , height ) {
207
230
this .activeComponentData .x = x;
@@ -214,6 +237,71 @@ export default {
214
237
this .componentMap [this .activeComponent ].w = width;
215
238
this .componentMap [this .activeComponent ].h = height;
216
239
},
240
+
241
+ recordInitialPosition : function (e ) {
242
+ console .log (" we started a drag" )
243
+ console .log (" this.intialPosition" ,this .initialPosition )
244
+ console .log (" WHAT IS THIS" , this )
245
+ if (this .activeComponent !== e .target .id ){
246
+ this .setActiveComponent (e .target .id )
247
+ }
248
+ this .initialPosition .x = this .activeComponentData .x
249
+ this .initialPosition .y = this .activeComponentData .y
250
+ // console.log(this.activeComponentData)
251
+ // console.log(this.activeComponentData.x)
252
+ // console.log(this.initialPosition.x)
253
+ // console.log(this.initialPosition.y)
254
+
255
+ let payload = {
256
+ x: this .initialPosition .x ,
257
+ y: this .initialPosition .y ,
258
+ activeComponent: this .activeComponent ,
259
+ routeArray: this .routes [this .activeRoute ],
260
+ activeComponentData: this .activeComponentData
261
+ }
262
+ console .log (" x: " ,payload .x ," y: " ,payload .y )
263
+ // this.updateStartingPosition(payload);
264
+ },
265
+
266
+ recordInitialSize : function (e ){
267
+ console .log (" MAKE MY MONSTER GROW!" )
268
+
269
+ this .initialSize .h = this .activeComponentData .h
270
+ this .initialSize .w = this .activeComponentData .w
271
+ this .initialPosition .x = this .activeComponentData .x
272
+ this .initialPosition .y = this .activeComponentData .y
273
+
274
+ let payload = {
275
+ h: this .initialSize .h ,
276
+ w: this .initialSize .w ,
277
+ x: this .activeComponentData .x ,
278
+ y: this .activeComponentData .y ,
279
+ activeComponent: this .activeComponent ,
280
+ routeArray: this .routes [this .activeRoute ],
281
+ activeComponentData: this .activeComponentData
282
+ }
283
+
284
+ // this.updateStartingSize(payload);
285
+
286
+ },
287
+
288
+ finishedResize : function (x ,y ,w ,h ){
289
+ console .log (" FINISHED RESIZING" )
290
+ let payload = {
291
+ x: x,
292
+ y: y,
293
+ w: w,
294
+ h: h,
295
+ activeComponent: this .activeComponent ,
296
+ routeArray: this .routes [this .activeRoute ],
297
+ activeComponentData: this .activeComponentData
298
+ }
299
+ if (payload .x !== this .initialPosition .x || payload .y !== this .initialPosition .y ||
300
+ payload .w !== this .initialSize .w || payload .h !== this .initialSize .h ){
301
+ this .updateComponentSize (payload)
302
+ }
303
+ },
304
+
217
305
onDrag : function (x , y ) {
218
306
this .activeComponentData .x = x;
219
307
this .activeComponentData .y = y;
@@ -222,19 +310,51 @@ export default {
222
310
this .componentMap [this .activeComponent ].y = y;
223
311
this .userImage ;
224
312
},
225
- onLayer : function (z ) {
226
- this .activeComponentData .z = z;
313
+ // onLayer: function(z) {
314
+ // this.activeComponentData.z = z;
315
+ // // Want to change the "Z" of the component found in Routes[activeRoute][whatever the component is]
316
+ // //have to do this via an action or it won't be preserved in our undo/redo
317
+ // },
318
+
319
+ finishedDrag : function (x ,y ){
320
+ console .log (" FINISHED DRAGGING" )
321
+ let payload = {
322
+ x: x,
323
+ y: y,
324
+ activeComponent: this .activeComponent ,
325
+ routeArray: this .routes [this .activeRoute ],
326
+ activeComponentData: this .activeComponentData
327
+ }
328
+ // console.log("Payload.x = ", payload.x, "this.initialPosition.x", this.initialPosition.x)
329
+ // console.log("Payload.y = ", payload.y, "this.initialPosition.y", this.initialPosition.y)
330
+ if (payload .x !== this .initialPosition .x || payload .y !== this .initialPosition .y ){
331
+ this .updateComponentPosition (payload);
332
+ }
227
333
},
334
+
228
335
onActivated (componentData ) {
336
+ <<<<<< < HEAD
229
337
this .$refs .boxes .forEach ((element )=> {
230
338
if (element .$attrs .id !== componentData .componentName ) {
231
339
element .enabled = false ;
340
+ ====== =
341
+ // console.log("I RAN!")
342
+ this .$refs .boxes .forEach ((element )=> {
343
+ if (element .$attrs .id !== componentData .componentName ){
344
+ element .enabled = false ;
345
+ >>>>>> > master
232
346
element .$emit (' deactivated' )
233
347
element .$emit (' update:active' , false )
234
348
}
235
349
})
236
- this .setActiveComponent (componentData .componentName );
350
+ // console.log("this is what is currently active",this.activeComponent)
351
+ // console.log("this is this", this)
352
+ // console.log('!(componentData.componentName === this.activeComponent)?',!(componentData.componentName === this.activeComponent))
353
+ if (! (componentData .componentName === this .activeComponent )){
354
+ this .setActiveComponent (componentData .componentName );
355
+ }
237
356
this .activeComponentData .isActive = true ;
357
+
238
358
239
359
},
240
360
@@ -252,7 +372,9 @@ export default {
252
372
// }
253
373
},
254
374
onDoubleClick (compData ) {
255
- this .setActiveComponent (compData .componentName );
375
+ if (! (componentData .componentName === this .activeComponent )){
376
+ this .setActiveComponent (componentData .componentName );
377
+ }
256
378
this .activeComponentData .isActive = true ;
257
379
},
258
380
handleAddChild () {
@@ -290,7 +412,9 @@ export default {
290
412
handleClick (event ) {
291
413
if (event .target .className === " component-display grid-bg" )
292
414
{
293
- this .setActiveComponent (' ' )
415
+ if (! (' ' === this .activeComponent )){
416
+ this .setActiveComponent (' ' );
417
+ }
294
418
}
295
419
}
296
420
}
@@ -309,7 +433,7 @@ export default {
309
433
/* width: 1rem; */
310
434
line- height: 1.2 ;
311
435
/* margin: 10px; */
312
- z-index : 0 ;
436
+ z- index: - 1 ;
313
437
}
314
438
.component - children {
315
439
position: absolute;
0 commit comments