chore(core): cleanup useUpdateNodePositions
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import type { NodeDragItem, SnapGrid, XYPosition } from '~/types'
|
import type { NodeDragItem, XYPosition } from '~/types'
|
||||||
|
|
||||||
function useUpdateNodePositions() {
|
function useUpdateNodePositions() {
|
||||||
const { getSelectedNodes, nodeExtent, updateNodePositions, findNode, snapGrid, snapToGrid } = useVueFlow()
|
const { getSelectedNodes, nodeExtent, updateNodePositions, findNode, snapGrid, snapToGrid } = useVueFlow()
|
||||||
@@ -13,24 +13,18 @@ function useUpdateNodePositions() {
|
|||||||
const positionDiffX = positionDiff.x * xVelo * factor
|
const positionDiffX = positionDiff.x * xVelo * factor
|
||||||
const positionDiffY = positionDiff.y * yVelo * factor
|
const positionDiffY = positionDiff.y * yVelo * factor
|
||||||
|
|
||||||
const nodeUpdates = getSelectedNodes.value.flatMap((n) => {
|
const nodeUpdates = getSelectedNodes.value.map((n) => {
|
||||||
if (n.computedPosition) {
|
const nextPosition = { x: n.computedPosition.x + positionDiffX, y: n.computedPosition.y + positionDiffY }
|
||||||
const nextPosition = { x: n.computedPosition.x + positionDiffX, y: n.computedPosition.y + positionDiffY }
|
|
||||||
|
|
||||||
const updatedPos = calcNextPosition(n, nextPosition, nodeExtent.value, n.parentNode ? findNode(n.parentNode) : undefined)
|
const updatedPos = calcNextPosition(n, nextPosition, nodeExtent.value, n.parentNode ? findNode(n.parentNode) : undefined)
|
||||||
|
|
||||||
return [
|
return {
|
||||||
{
|
id: n.id,
|
||||||
id: n.id,
|
position: updatedPos.position,
|
||||||
position: updatedPos.position,
|
from: n.position,
|
||||||
from: n.position,
|
distance: { x: positionDiff.x, y: positionDiff.y },
|
||||||
distance: { x: positionDiff.x, y: positionDiff.y },
|
dimensions: n.dimensions,
|
||||||
dimensions: n.dimensions,
|
} as NodeDragItem
|
||||||
},
|
|
||||||
] as NodeDragItem[]
|
|
||||||
}
|
|
||||||
|
|
||||||
return []
|
|
||||||
})
|
})
|
||||||
|
|
||||||
updateNodePositions(nodeUpdates, true, false)
|
updateNodePositions(nodeUpdates, true, false)
|
||||||
|
|||||||
Reference in New Issue
Block a user