fix(core): only emit position changes if change occurred (#1939)
* fix(core): only emit position changes if a position change occurred 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:
5
.changeset/selfish-cooks-jump.md
Normal file
5
.changeset/selfish-cooks-jump.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@vue-flow/core": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Only emit node position changes if a position change actually occurred.
|
||||||
@@ -74,6 +74,7 @@ export function useDrag(params: UseDragParams) {
|
|||||||
let mousePosition: XYPosition = { x: 0, y: 0 }
|
let mousePosition: XYPosition = { x: 0, y: 0 }
|
||||||
let dragEvent: MouseEvent | null = null
|
let dragEvent: MouseEvent | null = null
|
||||||
let dragStarted = false
|
let dragStarted = false
|
||||||
|
let nodePositionsChanged = false
|
||||||
|
|
||||||
let autoPanId = 0
|
let autoPanId = 0
|
||||||
let autoPanStarted = false
|
let autoPanStarted = false
|
||||||
@@ -104,6 +105,8 @@ export function useDrag(params: UseDragParams) {
|
|||||||
return n
|
return n
|
||||||
})
|
})
|
||||||
|
|
||||||
|
nodePositionsChanged = nodePositionsChanged || hasChange
|
||||||
|
|
||||||
if (!hasChange) {
|
if (!hasChange) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -187,6 +190,8 @@ export function useDrag(params: UseDragParams) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nodePositionsChanged = false
|
||||||
|
|
||||||
if (nodeDragThreshold.value === 0) {
|
if (nodeDragThreshold.value === 0) {
|
||||||
startDrag(event, nodeEl)
|
startDrag(event, nodeEl)
|
||||||
}
|
}
|
||||||
@@ -244,7 +249,10 @@ export function useDrag(params: UseDragParams) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dragItems.length && !isClick) {
|
if (dragItems.length && !isClick) {
|
||||||
|
if (nodePositionsChanged) {
|
||||||
updateNodePositions(dragItems, false, false)
|
updateNodePositions(dragItems, false, false)
|
||||||
|
nodePositionsChanged = false
|
||||||
|
}
|
||||||
|
|
||||||
const [currentNode, nodes] = getEventHandlerParams({
|
const [currentNode, nodes] = getEventHandlerParams({
|
||||||
id,
|
id,
|
||||||
|
|||||||
Reference in New Issue
Block a user