feat(nodes-edges): add nodesFocusable, edgesFocusable, cleanup keyboard controls
This commit is contained in:
@@ -9,17 +9,19 @@ function useUpdateNodePositions() {
|
||||
const store = useStoreApi();
|
||||
|
||||
const updatePositions = useCallback((positionDiff: XYPosition) => {
|
||||
const { nodeInternals, nodeExtent, updateNodePositions } = store.getState();
|
||||
const { nodeInternals, nodeExtent, updateNodePositions, snapToGrid, snapGrid } = store.getState();
|
||||
const selectedNodes = Array.from(nodeInternals.values()).filter((n) => n.selected);
|
||||
|
||||
const nodeUpdates = selectedNodes.map((n) => {
|
||||
if (n.positionAbsolute) {
|
||||
const updatedPos = calcNextPosition(
|
||||
n,
|
||||
{ x: n.positionAbsolute.x + positionDiff.x, y: n.positionAbsolute.y + positionDiff.y },
|
||||
nodeInternals,
|
||||
nodeExtent
|
||||
);
|
||||
const nextPosition = { x: n.positionAbsolute.x + positionDiff.x, y: n.positionAbsolute.y + positionDiff.y };
|
||||
|
||||
if (snapToGrid) {
|
||||
nextPosition.x = snapGrid[0] * Math.round(nextPosition.x / snapGrid[0]);
|
||||
nextPosition.y = snapGrid[1] * Math.round(nextPosition.y / snapGrid[1]);
|
||||
}
|
||||
|
||||
const updatedPos = calcNextPosition(n, nextPosition, nodeInternals, nodeExtent);
|
||||
|
||||
n.position = updatedPos.position;
|
||||
n.positionAbsolute = updatedPos.positionAbsolute;
|
||||
|
||||
Reference in New Issue
Block a user