feat(react,svelte): add nodeDragThreshold

This commit is contained in:
moklick
2023-09-26 13:08:27 +02:00
parent b1aeac0828
commit 348f311fc7
15 changed files with 94 additions and 47 deletions
@@ -56,6 +56,7 @@ type StoreUpdaterProps = Pick<
| 'connectionRadius'
| 'isValidConnection'
| 'selectNodesOnDrag'
| 'nodeDragThreshold'
> & { rfId: string };
const selector = (s: ReactFlowState) => ({
@@ -140,6 +141,7 @@ const StoreUpdater = ({
connectionRadius,
isValidConnection,
selectNodesOnDrag,
nodeDragThreshold,
}: StoreUpdaterProps) => {
const {
setNodes,
@@ -203,6 +205,7 @@ const StoreUpdater = ({
useDirectStoreUpdater('connectionRadius', connectionRadius, store.setState);
useDirectStoreUpdater('isValidConnection', isValidConnection, store.setState);
useDirectStoreUpdater('selectNodesOnDrag', selectNodesOnDrag, store.setState);
useDirectStoreUpdater('nodeDragThreshold', nodeDragThreshold, store.setState);
useStoreUpdater<Node[]>(nodes, setNodes);
useStoreUpdater<Edge[]>(edges, setEdges);
@@ -163,6 +163,7 @@ const ReactFlow = forwardRef<ReactFlowRefType, ReactFlowProps>(
onError,
style,
id,
nodeDragThreshold,
...rest
},
ref
@@ -292,6 +293,7 @@ const ReactFlow = forwardRef<ReactFlowRefType, ReactFlowProps>(
connectionRadius={connectionRadius}
isValidConnection={isValidConnection}
selectNodesOnDrag={selectNodesOnDrag}
nodeDragThreshold={nodeDragThreshold}
/>
<SelectionListener onSelectionChange={onSelectionChange} />
{children}
+1
View File
@@ -28,6 +28,7 @@ const initialState: ReactFlowStore = {
paneDragging: false,
noPanClassName: 'nopan',
nodeOrigin: [0, 0],
nodeDragThreshold: 0,
snapGrid: [15, 15],
snapToGrid: false,
@@ -148,6 +148,7 @@ export type ReactFlowProps = HTMLAttributes<HTMLDivElement> & {
connectionRadius?: number;
onError?: OnError;
isValidConnection?: IsValidConnection;
nodeDragThreshold?: number;
};
export type ReactFlowRefType = HTMLDivElement;
+1
View File
@@ -61,6 +61,7 @@ export type ReactFlowStore = {
translateExtent: CoordinateExtent;
nodeExtent: CoordinateExtent;
nodeOrigin: NodeOrigin;
nodeDragThreshold: number;
nodesSelectionActive: boolean;
userSelectionActive: boolean;