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

Fix the fix and extra fix

parent 9be3ba8f
Pipeline #53033 passed with stage
in 42 seconds
......@@ -127,6 +127,7 @@ export default {
activePreview: { row: null, type: null },
dragEnabled: true,
dragging: false,
stoppedDrag: false,
deleting: false,
resizing: false
}
......@@ -381,19 +382,24 @@ export default {
const colElement = document.getElementById(row + ',' + col);
event.dataTransfer.setDragImage(colElement, colElement.offsetWidth/2, 20);
this.draggedBlock = { row, col };
// Workaround for a bug in Chrome causing dragend
// to be fired immediately if the timeout is not used
this.stoppedDrag = false;
setTimeout(() => {
this.draggedBlock = { row, col };
if (this.stoppedDrag) return;
this.dragging = true;
this.showDropPreview(event, row, col);
}, 10);
this.showDropPreview(row, col);
}, 9);
},
stopDrag() {
this.dragging = false;
this.hidePreview();
this.stoppedDrag = true;
},
getDropPosition(event, row) {
......@@ -440,6 +446,9 @@ export default {
// Shows a preview upon dragging a block over a row
dragHover(event, row) {
if (!this.dragging)
return;
event.dataTransfer.dropEffect = 'move';
let position = this.getDropPosition(event, row);
......@@ -448,12 +457,12 @@ export default {
if (position === null)
return;
this.showDropPreview(event, row, position);
this.showDropPreview(row, position);
event.preventDefault();
},
showDropPreview(event, row, position) {
showDropPreview(row, position) {
const origRow = this.draggedBlock.row;
const origCol = this.draggedBlock.col;
const origBlock = this.layout[origRow].blocks[origCol];
......@@ -472,6 +481,9 @@ export default {
},
drop(event, row) {
if (!this.dragging)
return;
const position = this.getDropPosition(event, row);
// Do nothing if row full
......@@ -508,7 +520,7 @@ export default {
}
}
this.hidePreview();
this.stopDrag();
this.saveLayout("isaac");
},
......
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