remove unnecessary touch and mouse events from dashboard

This commit is contained in:
chfhtw
2026-04-13 10:45:54 +02:00
parent 6c90ccfbaa
commit a8f680810f
3 changed files with 4 additions and 57 deletions
+1 -1
View File
@@ -251,7 +251,7 @@ export default {
<div
v-if="item.placeholder"
class="empty-tile-hover"
@pointerdown="$emit('widgetAdd', name, { widget: 1, config: {}, place: {[gridWidth]: {x:item.x,y:item.y,w:1,h:1}}, custom: 1 })"
@click="$emit('widgetAdd', name, { widget: 1, config: {}, place: {[gridWidth]: {x:item.x,y:item.y,w:1,h:1}}, custom: 1 })"
></div>
<dashboard-item
v-else
-12
View File
@@ -588,12 +588,6 @@ export default {
for (let i = 0; i < widgetClones.length; i++) {
this.$refs.container.removeChild(widgetClones[i]);
}
},
mouseDown() {
this.mode = MODE_MOUSE_DOWN;
},
mouseUp() {
this.mode = MODE_IDLE;
}
},
template: /* html */`
@@ -601,8 +595,6 @@ export default {
ref="container"
class="drop-grid position-relative h-0"
:style="gridStyle"
@touchmove="dragOver"
@touchend="dragCancel"
@dragover.prevent="dragOver"
@drop="dragEnd"
>
@@ -623,13 +615,9 @@ export default {
padding: 'var(--fhc-dg-item-padding)'
}"
@start-move="startMove"
@mouse-down="mouseDown"
@mouse-up="mouseUp"
@start-resize="startResize"
@dragging="dragging"
@end-drag="dragEnd"
@touch-end="dragEnd();mouseUp();"
@touch-start="mouseDown"
>
<template v-slot="item">
<slot
+3 -44
View File
@@ -5,75 +5,34 @@ export default {
active: Boolean
},
emits: [
"mouseDown",
"mouseUp",
"startMove",
"startResize",
"dragging",
"endDrag",
"touchStart",
"touchEnd"
"endDrag"
],
data() {
return {
dragAction: '',
dragging: false
};
},
methods: {
registerDragAction(evt) {
this.$emit('mouseDown', evt);
if (evt.target.hasAttribute('drag-action')) {
this.dragAction = evt.target.getAttribute('drag-action');
} else {
let parent = evt.target.closest('[drag-action]');
if (parent) {
this.dragAction = parent.getAttribute('drag-action');
} else {
this.dragAction = '';
}
}
},
tryDragStart(evt) {
let dragAction = this.dragAction || evt.target.getAttribute('drag-action');
let dragAction = evt.target.getAttribute('drag-action');
if (dragAction) {
this.dragging = true;
if (dragAction == 'move')
return this.$emit('startMove', evt, this.item);
else if (dragAction == 'resize')
return this.$emit('startResize', evt, this.item);
}
},
touchDragEnd(evt) {
if (!this.dragging)
return;
this.dragging = false;
this.$emit('touchEnd', evt);
},
touchStart(event) {
this.$emit('touchStart', event);
this.registerDragAction(event);
this.tryDragStart(event);
},
touchMove(event) {
if (this.dragging) {
event.preventDefault();
this.$emit('dragging', event);
}
}
},
template: /* html */`
<div
class="drop-grid-item"
@mousedown="registerDragAction"
@mouseup="$emit('mouseUp', $event)"
@touchstart="touchStart"
@touchend="touchDragEnd"
@dragstart="tryDragStart"
@drag="$emit('dragging', $event)"
@touchmove="touchMove"
@dragend="$emit('endDrag', $event); dragging = false"
@dragend="$emit('endDrag', $event)"
>
<slot v-bind="item"></slot>
</div>`