Skip to content

Commit aa9f061

Browse files
author
s.edelmann
committed
loading placeholder x and y coordinates by layout item instead of drag event data
1 parent 1c6e509 commit aa9f061

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/components/GridLayout.vue

Lines changed: 11 additions & 8 deletions
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.

0 commit comments

Comments
 (0)