streamlined connections
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
EdgeSelectionChange,
|
||||
NodeSelectionChange,
|
||||
ParentExpandChild,
|
||||
initialConnection,
|
||||
} from '@xyflow/system';
|
||||
|
||||
import { applyEdgeChanges, applyNodeChanges, createSelectionChange, getSelectionChanges } from '../utils/changes';
|
||||
@@ -308,27 +309,12 @@ const createStore = ({
|
||||
);
|
||||
},
|
||||
cancelConnection: () => {
|
||||
const { connection } = get();
|
||||
set({
|
||||
connection: {
|
||||
position: connection.position,
|
||||
fromHandle: null,
|
||||
toHandle: null,
|
||||
isValid: null,
|
||||
},
|
||||
connection: { ...initialConnection },
|
||||
});
|
||||
},
|
||||
updateConnection: (params) => {
|
||||
const { connection } = get();
|
||||
|
||||
const currentConnection = {
|
||||
connection: {
|
||||
...params,
|
||||
position: params.position ?? connection.position,
|
||||
},
|
||||
};
|
||||
|
||||
set(currentConnection);
|
||||
updateConnection: (connection) => {
|
||||
set({ connection });
|
||||
},
|
||||
|
||||
reset: () => set({ ...getInitialState() }),
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
updateConnectionLookup,
|
||||
devWarn,
|
||||
getInternalNodesBounds,
|
||||
initialConnection,
|
||||
} from '@xyflow/system';
|
||||
|
||||
import type { Edge, InternalNode, Node, ReactFlowStore } from '../types';
|
||||
@@ -101,12 +102,7 @@ const getInitialState = ({
|
||||
|
||||
multiSelectionActive: false,
|
||||
|
||||
connection: {
|
||||
fromHandle: null,
|
||||
toHandle: null,
|
||||
position: { x: 0, y: 0 },
|
||||
isValid: null,
|
||||
},
|
||||
connection: { ...initialConnection },
|
||||
connectionClickStartHandle: null,
|
||||
connectOnClick: true,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user