Commit 60edb6af authored by Lasse Overgaard Møldrup's avatar Lasse Overgaard Møldrup
Browse files

Fixed bug causing a 'phantom' block to appear when moving

parent 6e829409
......@@ -3,7 +3,7 @@
<div id="grid">
<div @mousedown="resizeVertical($event, rowIndex)" :id="rowIndex" class="row" :class="{ drag: draggedBlock !== null }"
v-for="(rowBlock, rowIndex) in layout" :key="rowIndex" :style="{ height: rowBlock.height + 'px' }"
@dragover="dragHover($event, rowIndex)" @dragleave="hidePreview(rowIndex)" @drop="drop($event, rowIndex)">
@dragover="dragHover($event, rowIndex)" @dragleave="hidePreview()" @drop="drop($event, rowIndex)">
<span class="col-preview">
<component :is="previewType"></component>
</span>
......@@ -63,6 +63,7 @@ export default {
verticalResizeObject: {index: 0},
horizontalResizeObject: {row: 0, col: 0},
draggedBlock: null,
activePreview: null,
dragEnabled: true
}
},
......@@ -218,7 +219,7 @@ export default {
dragHover(event, row) {
event.dataTransfer.dropEffect = 'move';
let position = this.getDropPosition(event,row);
let position = this.getDropPosition(event, row);
// Don't show preview if row is full
if (position === null)
......@@ -230,6 +231,10 @@ export default {
},
showDropPreview(row, position) {
if (this.activePreview !== null)
this.hidePreview();
this.activePreview = row;
const origRow = this.draggedBlock.row;
const origCol = this.draggedBlock.col;
const origBlock = this.layout[origRow].blocks[origCol];
......@@ -247,7 +252,7 @@ export default {
},
drop(event, row) {
this.hidePreview(row);
this.hidePreview();
const position = this.getDropPosition(event, row);
......@@ -288,10 +293,14 @@ export default {
this.draggedBlock = null;
},
hidePreview(row) {
const targetRow = document.getElementById(row.toString());
hidePreview() {
if (this.activePreview === null)
return;
const targetRow = document.getElementById(this.activePreview.toString());
const preview = targetRow.getElementsByClassName('col-preview')[0];
preview.style.display = 'none';
this.activePreview = null;
},
isDragged(row, col) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment