feat(props): add connectionDragThreshold
This commit is contained in:
@@ -92,6 +92,7 @@ export function EdgeUpdateAnchors<EdgeType extends Edge = Edge>({
|
|||||||
updateConnection,
|
updateConnection,
|
||||||
getTransform: () => store.getState().transform,
|
getTransform: () => store.getState().transform,
|
||||||
getFromHandle: () => store.getState().connection.fromHandle,
|
getFromHandle: () => store.getState().connection.fromHandle,
|
||||||
|
dragThreshold: store.getState().connectionDragThreshold,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ function HandleComponent(
|
|||||||
getTransform: () => store.getState().transform,
|
getTransform: () => store.getState().transform,
|
||||||
getFromHandle: () => store.getState().connection.fromHandle,
|
getFromHandle: () => store.getState().connection.fromHandle,
|
||||||
autoPanSpeed: currentStore.autoPanSpeed,
|
autoPanSpeed: currentStore.autoPanSpeed,
|
||||||
|
dragThreshold: currentStore.connectionDragThreshold,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ const reactFlowFieldsToTrack = [
|
|||||||
'isValidConnection',
|
'isValidConnection',
|
||||||
'selectNodesOnDrag',
|
'selectNodesOnDrag',
|
||||||
'nodeDragThreshold',
|
'nodeDragThreshold',
|
||||||
|
'connectionDragThreshold',
|
||||||
'onBeforeDelete',
|
'onBeforeDelete',
|
||||||
'debug',
|
'debug',
|
||||||
'autoPanSpeed',
|
'autoPanSpeed',
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ function ReactFlow<NodeType extends Node = Node, EdgeType extends Edge = Edge>(
|
|||||||
style,
|
style,
|
||||||
id,
|
id,
|
||||||
nodeDragThreshold,
|
nodeDragThreshold,
|
||||||
|
connectionDragThreshold,
|
||||||
viewport,
|
viewport,
|
||||||
onViewportChange,
|
onViewportChange,
|
||||||
width,
|
width,
|
||||||
@@ -306,6 +307,7 @@ function ReactFlow<NodeType extends Node = Node, EdgeType extends Edge = Edge>(
|
|||||||
isValidConnection={isValidConnection}
|
isValidConnection={isValidConnection}
|
||||||
selectNodesOnDrag={selectNodesOnDrag}
|
selectNodesOnDrag={selectNodesOnDrag}
|
||||||
nodeDragThreshold={nodeDragThreshold}
|
nodeDragThreshold={nodeDragThreshold}
|
||||||
|
connectionDragThreshold={connectionDragThreshold}
|
||||||
onBeforeDelete={onBeforeDelete}
|
onBeforeDelete={onBeforeDelete}
|
||||||
paneClickDistance={paneClickDistance}
|
paneClickDistance={paneClickDistance}
|
||||||
debug={debug}
|
debug={debug}
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ const getInitialState = ({
|
|||||||
noPanClassName: 'nopan',
|
noPanClassName: 'nopan',
|
||||||
nodeOrigin: storeNodeOrigin,
|
nodeOrigin: storeNodeOrigin,
|
||||||
nodeDragThreshold: 1,
|
nodeDragThreshold: 1,
|
||||||
|
connectionDragThreshold: 1,
|
||||||
|
|
||||||
snapGrid: [15, 15],
|
snapGrid: [15, 15],
|
||||||
snapToGrid: false,
|
snapToGrid: false,
|
||||||
|
|||||||
@@ -657,6 +657,12 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
|
|||||||
* @default 1
|
* @default 1
|
||||||
*/
|
*/
|
||||||
nodeDragThreshold?: number;
|
nodeDragThreshold?: number;
|
||||||
|
/**
|
||||||
|
* The threshold in pixels that the mouse must move before a connection line starts to drag.
|
||||||
|
* This is useful to prevent accidental connections when clicking on a handle.
|
||||||
|
* @default 1
|
||||||
|
*/
|
||||||
|
connectionDragThreshold?: number;
|
||||||
/** Sets a fixed width for the flow. */
|
/** Sets a fixed width for the flow. */
|
||||||
width?: number;
|
width?: number;
|
||||||
/** Sets a fixed height for the flow. */
|
/** Sets a fixed height for the flow. */
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ export type ReactFlowStore<NodeType extends Node = Node, EdgeType extends Edge =
|
|||||||
nodeExtent: CoordinateExtent;
|
nodeExtent: CoordinateExtent;
|
||||||
nodeOrigin: NodeOrigin;
|
nodeOrigin: NodeOrigin;
|
||||||
nodeDragThreshold: number;
|
nodeDragThreshold: number;
|
||||||
|
connectionDragThreshold: number;
|
||||||
|
|
||||||
nodesSelectionActive: boolean;
|
nodesSelectionActive: boolean;
|
||||||
userSelectionActive: boolean;
|
userSelectionActive: boolean;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
import { getContext } from 'svelte';
|
import { getContext } from 'svelte';
|
||||||
import { EdgeLabel } from '../EdgeLabel';
|
import { EdgeLabel } from '../EdgeLabel';
|
||||||
import type { EdgeReconnectAnchorProps } from './types';
|
import type { EdgeReconnectAnchorProps } from './types';
|
||||||
|
import drag from '$lib/actions/drag';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
type,
|
type,
|
||||||
@@ -97,7 +98,8 @@
|
|||||||
},
|
},
|
||||||
updateConnection,
|
updateConnection,
|
||||||
getTransform: () => [store.viewport.x, store.viewport.y, store.viewport.zoom],
|
getTransform: () => [store.viewport.x, store.viewport.y, store.viewport.zoom],
|
||||||
getFromHandle: () => store.connection.fromHandle
|
getFromHandle: () => store.connection.fromHandle,
|
||||||
|
dragThreshold: store.connectionDragThreshold
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -139,7 +139,8 @@
|
|||||||
store.onconnectend?.(event, connectionState);
|
store.onconnectend?.(event, connectionState);
|
||||||
},
|
},
|
||||||
getTransform: () => [store.viewport.x, store.viewport.y, store.viewport.zoom],
|
getTransform: () => [store.viewport.x, store.viewport.y, store.viewport.zoom],
|
||||||
getFromHandle: () => store.connection.fromHandle
|
getFromHandle: () => store.connection.fromHandle,
|
||||||
|
dragThreshold: store.connectionDragThreshold
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,6 +170,12 @@ export type SvelteFlowProps<
|
|||||||
* @default 0
|
* @default 0
|
||||||
*/
|
*/
|
||||||
nodeClickDistance?: number;
|
nodeClickDistance?: number;
|
||||||
|
/**
|
||||||
|
* The threshold in pixels that the mouse must move before a connection line starts to drag.
|
||||||
|
* This is useful to prevent accidental connections when clicking on a handle.
|
||||||
|
* @default 1
|
||||||
|
*/
|
||||||
|
connectionDragThreshold?: number;
|
||||||
/** Minimum zoom level
|
/** Minimum zoom level
|
||||||
* @default 0.5
|
* @default 0.5
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -286,6 +286,7 @@ export function getInitialStore<NodeType extends Node = Node, EdgeType extends E
|
|||||||
autoPanOnNodeDrag: boolean = $derived(signals.props.autoPanOnNodeDrag ?? true);
|
autoPanOnNodeDrag: boolean = $derived(signals.props.autoPanOnNodeDrag ?? true);
|
||||||
autoPanOnConnect: boolean = $derived(signals.props.autoPanOnConnect ?? true);
|
autoPanOnConnect: boolean = $derived(signals.props.autoPanOnConnect ?? true);
|
||||||
autoPanOnNodeFocus: boolean = $derived(signals.props.autoPanOnNodeFocus ?? true);
|
autoPanOnNodeFocus: boolean = $derived(signals.props.autoPanOnNodeFocus ?? true);
|
||||||
|
connectionDragThreshold: number = $derived(signals.props.connectionDragThreshold ?? 1);
|
||||||
|
|
||||||
fitViewQueued: boolean = signals.props.fitView ?? false;
|
fitViewQueued: boolean = signals.props.fitView ?? false;
|
||||||
fitViewOptions: FitViewOptions | undefined = signals.props.fitViewOptions;
|
fitViewOptions: FitViewOptions | undefined = signals.props.fitViewOptions;
|
||||||
|
|||||||
Reference in New Issue
Block a user