[UI] Improved Draggable component events.

`Draggable` components should emit `dragend`, not `drop` events.

`drop` should only be emitted by `Droppable` components, or the receiver
of a component that uses both won't be able to tell if a `drop` event
came from a component being dragged, or from an element where a dragged
element was dropped.
This commit is contained in:
Fabio Manganiello 2024-09-10 22:54:12 +02:00
parent 471ec1370c
commit daa030ff4c
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -13,6 +13,7 @@ export default {
emits: [
'contextmenu',
'drag',
'dragend',
'drop',
],
@ -37,7 +38,7 @@ export default {
},
value: {
type: Object,
type: [Object, String, Number, Boolean, Array],
default: () => ({}),
},
},
@ -51,8 +52,8 @@ export default {
drag: this.onDrag,
dragend: this.onDragEnd,
dragstart: this.onDragStart,
drop: this.onDrop,
touchcancel: this.onDrop,
drop: this.onDragEnd,
touchcancel: this.onDragEnd,
touchend: this.onTouchEnd,
touchmove: this.onTouchMove,
touchstart: this.onTouchStart,
@ -121,7 +122,7 @@ export default {
}
this.reset()
this.$emit('drop', event)
this.$emit('dragend', event)
},
onTouchStart(event) {
@ -242,15 +243,6 @@ export default {
this.onDragEnd(event)
},
onDrop(event) {
if (this.disabled) {
return
}
this.reset()
this.$emit('drop', event)
},
handleTouchScroll(value, parent) {
this.touchScrollDirection = value
if (!(value[0] || value[1])) {