Skip to content

Commit 1636cbe

Browse files
authored
Merge pull request #260 from shpfive/overlapping
Overlapping #239
2 parents 37895a4 + 0735635 commit 1636cbe

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/components/GridLayout.vue

+16-15
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,17 @@
266266
return bottom(this.layout) * (this.rowHeight + this.margin[1]) + this.margin[1] + 'px';
267267
},
268268
dragEvent: function (eventName, id, x, y, h, w) {
269+
//console.log(eventName + " id=" + id + ", x=" + x + ", y=" + y);
270+
let l = getLayoutItem(this.layout, id);
271+
//GetLayoutItem sometimes returns null object
272+
if (l === undefined || l === null){
273+
l = {x:0, y:0}
274+
}
275+
269276
if (eventName === "dragmove" || eventName === "dragstart") {
270277
this.placeholder.i = id;
271-
this.placeholder.x = x;
272-
this.placeholder.y = y;
278+
this.placeholder.x = l.x;
279+
this.placeholder.y = l.y;
273280
this.placeholder.w = w;
274281
this.placeholder.h = h;
275282
this.$nextTick(function() {
@@ -282,12 +289,8 @@
282289
this.isDragging = false;
283290
});
284291
}
285-
//console.log(eventName + " id=" + id + ", x=" + x + ", y=" + y);
286-
let l = getLayoutItem(this.layout, id);
287-
//GetLayoutItem sometimes returns null object
288-
if (l === undefined || l === null){
289-
l = {x:0, y:0}
290-
}
292+
293+
// set layout element coordinates to dragged position
291294
l.x = x;
292295
l.y = y;
293296
// Move the element to the dragged location.
@@ -324,13 +327,11 @@
324327
l.h = h;
325328
l.w = w;
326329
327-
if (this.responsive){
328-
this.responsiveGridLayout();
329-
}else{
330-
compact(this.layout, this.verticalCompact);
331-
this.eventBus.$emit("compact");
332-
this.updateHeight();
333-
}
330+
if (this.responsive) this.responsiveGridLayout();
331+
332+
compact(this.layout, this.verticalCompact);
333+
this.eventBus.$emit("compact");
334+
this.updateHeight();
334335
335336
if (eventName === 'resizeend') this.$emit('layout-updated', this.layout);
336337
},

0 commit comments

Comments
 (0)