fix(nodeOrigin): use origin for calculating handle position

This commit is contained in:
moklick
2022-09-01 12:37:13 +02:00
parent 2172522a0b
commit 23fdd20658
6 changed files with 27 additions and 7 deletions
+11 -3
View File
@@ -40,7 +40,15 @@ const createRFStore = () =>
set({ nodeInternals, edges: nextEdges, hasDefaultNodes, hasDefaultEdges });
},
updateNodeDimensions: (updates: NodeDimensionUpdate[]) => {
const { onNodesChange, nodeInternals, fitViewOnInit, fitViewOnInitDone, fitViewOnInitOptions, domNode } = get();
const {
onNodesChange,
nodeInternals,
fitViewOnInit,
fitViewOnInitDone,
fitViewOnInitOptions,
domNode,
nodeOrigin,
} = get();
const viewportNode = domNode?.querySelector('.react-flow__viewport');
if (!viewportNode) {
@@ -67,8 +75,8 @@ const createRFStore = () =>
[internalsSymbol]: {
...node[internalsSymbol],
handleBounds: {
source: getHandleBounds('.source', update.nodeElement, zoom),
target: getHandleBounds('.target', update.nodeElement, zoom),
source: getHandleBounds('.source', update.nodeElement, zoom, nodeOrigin),
target: getHandleBounds('.target', update.nodeElement, zoom, nodeOrigin),
},
},
...dimensions,
+1
View File
@@ -32,6 +32,7 @@ const initialState: ReactFlowStore = {
domNode: null,
paneDragging: false,
noPanClassName: 'nopan',
nodeOrigin: [0, 0],
snapGrid: [15, 15],
snapToGrid: false,