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 dragEvent: MouseEvent | null = null
|
||||
let dragStarted = false
|
||||
let nodePositionsChanged = false
|
||||
|
||||
let autoPanId = 0
|
||||
let autoPanStarted = false
|
||||
@@ -104,6 +105,8 @@ export function useDrag(params: UseDragParams) {
|
||||
return n
|
||||
})
|
||||
|
||||
nodePositionsChanged = nodePositionsChanged || hasChange
|
||||
|
||||
if (!hasChange) {
|
||||
return
|
||||
}
|
||||
@@ -187,6 +190,8 @@ export function useDrag(params: UseDragParams) {
|
||||
return
|
||||
}
|
||||
|
||||
nodePositionsChanged = false
|
||||
|
||||
if (nodeDragThreshold.value === 0) {
|
||||
startDrag(event, nodeEl)
|
||||
}
|
||||
@@ -244,7 +249,10 @@ export function useDrag(params: UseDragParams) {
|
||||
}
|
||||
|
||||
if (dragItems.length && !isClick) {
|
||||
if (nodePositionsChanged) {
|
||||
updateNodePositions(dragItems, false, false)
|
||||
nodePositionsChanged = false
|
||||
}
|
||||
|
||||
const [currentNode, nodes] = getEventHandlerParams({
|
||||
id,
|
||||
|
||||
Reference in New Issue
Block a user