get rid of toggleDraggedItemOverlay and replace it with css classes that are computed inside the template

This commit is contained in:
chfhtw
2026-04-13 13:21:35 +02:00
parent e98ed3c74f
commit 9fd033b30e
2 changed files with 14 additions and 27 deletions
+4 -17
View File
@@ -46,7 +46,6 @@ export default {
correctedPositionUpdates: null,
draggedOffset: [0, 0],
draggedItem: null,
draggedNode: null,
reorderedItems: [],
clonedWidget: null,
};
@@ -241,19 +240,8 @@ export default {
}
return false;
},
toggleDraggedItemOverlay(condition) {
if (!this.draggedNode)
return;
if (condition) {
this.draggedNode.firstElementChild.classList.add("dashboard-item-overlay");
} else {
this.draggedNode.firstElementChild.classList.remove("dashboard-item-overlay");
}
},
moveGhostImage(event) {
if (this.mode == MODE_MOVE) {
this.toggleDraggedItemOverlay(true);
const containerRect = this.$refs.container.getBoundingClientRect();
const clonedWidgetRect = this.clonedWidget.getBoundingClientRect();
@@ -394,7 +382,6 @@ export default {
this.$emit('draggedItem', item);
this.draggedNode = evt.target.closest(".drop-grid-item");
//clones the widget for the drag Image
// NOTE(chris): this is the element that follows the mouse while dragging
@@ -474,17 +461,14 @@ export default {
dragCancel() {
this.removeWidgetClones();
this.additionalRowComputed = false;
this.toggleDraggedItemOverlay(false);
this.mode = MODE_IDLE;
this.tempPositionUpdates = null;
this.draggedOffset = [0,0],
this.draggedItem = null;
this.$emit('draggedItem',null);
this.draggedNode = null;
},
dragEnd() {
this.removeWidgetClones();
this.toggleDraggedItemOverlay(false);
if (this.mode == MODE_IDLE) {
return;
@@ -507,7 +491,6 @@ export default {
this.$emit('rearrangeItems', updated.filter(v => v));
this.draggedItem = null;
this.draggedNode = null;
this.$emit('draggedItem', null);
},
_updateCorrectedPositions(updated) {
@@ -603,6 +586,10 @@ export default {
v-for="(item, index) in currentItems"
:key="item.data.id"
class="position-absolute"
:class="{
'drop-grid-item-move': item.index == draggedItem?.index && mode == 1,
'drop-grid-item-resize': item.index == draggedItem?.index && mode == 2
}"
:item="item"
:style="{
zIndex: item.resizeOverlay ? 1 : 'auto',