fix(core): reset drag items on drag end (#1798)
* fix(core): reset drag items on drag end Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> * chore(changeset): add Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> --------- Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@vue-flow/core": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Reset drag items on drag end
|
||||||
@@ -12,7 +12,6 @@ import {
|
|||||||
getEventPosition,
|
getEventPosition,
|
||||||
handleNodeClick,
|
handleNodeClick,
|
||||||
hasSelector,
|
hasSelector,
|
||||||
isUseDragEvent,
|
|
||||||
snapPosition,
|
snapPosition,
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
import { useGetPointerPosition, useVueFlow } from '.'
|
import { useGetPointerPosition, useVueFlow } from '.'
|
||||||
@@ -226,8 +225,10 @@ export function useDrag(params: UseDragParams) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const eventEnd = (event: UseDragEvent) => {
|
const eventEnd = (event: UseDragEvent) => {
|
||||||
if (!isUseDragEvent(event) && !dragStarted && !dragging.value && !multiSelectionActive.value) {
|
let isClick = false
|
||||||
const evt = event as MouseTouchEvent
|
|
||||||
|
if (!dragStarted && !dragging.value && !multiSelectionActive.value) {
|
||||||
|
const evt = event.sourceEvent as MouseTouchEvent
|
||||||
|
|
||||||
const pointerPos = getPointerPosition(evt)
|
const pointerPos = getPointerPosition(evt)
|
||||||
|
|
||||||
@@ -238,19 +239,11 @@ export function useDrag(params: UseDragParams) {
|
|||||||
// dispatch a click event if the node was attempted to be dragged but the threshold was not exceeded
|
// dispatch a click event if the node was attempted to be dragged but the threshold was not exceeded
|
||||||
if (distance !== 0 && distance <= nodeDragThreshold.value) {
|
if (distance !== 0 && distance <= nodeDragThreshold.value) {
|
||||||
onClick?.(evt)
|
onClick?.(evt)
|
||||||
|
isClick = true
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dragging.value = false
|
if (dragItems.length && !isClick) {
|
||||||
autoPanStarted = false
|
|
||||||
dragStarted = false
|
|
||||||
lastPos = { x: undefined, y: undefined }
|
|
||||||
|
|
||||||
cancelAnimationFrame(autoPanId)
|
|
||||||
|
|
||||||
if (dragItems.length) {
|
|
||||||
updateNodePositions(dragItems, false, false)
|
updateNodePositions(dragItems, false, false)
|
||||||
|
|
||||||
const [currentNode, nodes] = getEventHandlerParams({
|
const [currentNode, nodes] = getEventHandlerParams({
|
||||||
@@ -261,6 +254,14 @@ export function useDrag(params: UseDragParams) {
|
|||||||
|
|
||||||
onStop({ event: event.sourceEvent, node: currentNode, nodes })
|
onStop({ event: event.sourceEvent, node: currentNode, nodes })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dragItems = []
|
||||||
|
dragging.value = false
|
||||||
|
autoPanStarted = false
|
||||||
|
dragStarted = false
|
||||||
|
lastPos = { x: undefined, y: undefined }
|
||||||
|
|
||||||
|
cancelAnimationFrame(autoPanId)
|
||||||
}
|
}
|
||||||
|
|
||||||
watch([() => toValue(disabled), el], ([isDisabled, nodeEl], _, onCleanup) => {
|
watch([() => toValue(disabled), el], ([isDisabled, nodeEl], _, onCleanup) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user