feat(core,nodes): implement a11y in nodes

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2022-12-20 00:38:56 +01:00
committed by Braks
parent 0267b2f19e
commit 9f50dd0865
17 changed files with 167 additions and 35 deletions
@@ -0,0 +1,32 @@
import type { NodeDragItem, XYPosition } from '~/types'
function useUpdateNodePositions() {
const { getSelectedNodes, nodeExtent, updateNodePositions, findNode } = useVueFlow()
return (positionDiff: XYPosition) => {
const nodeUpdates = getSelectedNodes.value.flatMap((n) => {
if (n.computedPosition) {
const nextPosition = { x: n.computedPosition.x + positionDiff.x, y: n.computedPosition.y + positionDiff.y }
const updatedPos = calcNextPosition(n, nextPosition, nodeExtent.value, n.parentNode ? findNode(n.parentNode) : undefined)
return [
{
id: n.id,
position: updatedPos.position,
computedPosition: { ...n.computedPosition, ...updatedPos.computedPosition },
from: n.position,
distance: { x: positionDiff.x, y: positionDiff.y },
dimensions: n.dimensions,
},
] as NodeDragItem[]
}
return []
})
updateNodePositions(nodeUpdates, true, true)
}
}
export default useUpdateNodePositions