|
266 | 266 | return bottom(this.layout) * (this.rowHeight + this.margin[1]) + this.margin[1] + 'px';
|
267 | 267 | },
|
268 | 268 | 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 | + |
269 | 276 | if (eventName === "dragmove" || eventName === "dragstart") {
|
270 | 277 | 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; |
273 | 280 | this.placeholder.w = w;
|
274 | 281 | this.placeholder.h = h;
|
275 | 282 | this.$nextTick(function() {
|
|
282 | 289 | this.isDragging = false;
|
283 | 290 | });
|
284 | 291 | }
|
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 |
291 | 294 | l.x = x;
|
292 | 295 | l.y = y;
|
293 | 296 | // Move the element to the dragged location.
|
|
324 | 327 | l.h = h;
|
325 | 328 | l.w = w;
|
326 | 329 |
|
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(); |
334 | 335 |
|
335 | 336 | if (eventName === 'resizeend') this.$emit('layout-updated', this.layout);
|
336 | 337 | },
|
|
0 commit comments