feat(nodes): add selectNodesOnDrag prop type
This commit is contained in:
@@ -33,6 +33,7 @@ export interface GraphViewProps {
|
||||
snapGrid: [number, number];
|
||||
onlyRenderVisibleNodes: boolean;
|
||||
isInteractive: boolean;
|
||||
selectNodesOnDrag: boolean;
|
||||
}
|
||||
|
||||
const GraphView = memo(
|
||||
@@ -55,6 +56,7 @@ const GraphView = memo(
|
||||
snapGrid,
|
||||
onlyRenderVisibleNodes,
|
||||
isInteractive,
|
||||
selectNodesOnDrag,
|
||||
}: GraphViewProps) => {
|
||||
const zoomPane = useRef<HTMLDivElement>(null);
|
||||
const rendererNode = useRef<HTMLDivElement>(null);
|
||||
@@ -132,6 +134,7 @@ const GraphView = memo(
|
||||
onNodeDragStop={onNodeDragStop}
|
||||
onNodeDragStart={onNodeDragStart}
|
||||
onlyRenderVisibleNodes={onlyRenderVisibleNodes}
|
||||
selectNodesOnDrag={selectNodesOnDrag}
|
||||
/>
|
||||
<EdgeRenderer
|
||||
width={width}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Node, Transform, NodeTypesType, WrapNodeProps, Elements, Edge } from '.
|
||||
|
||||
interface NodeRendererProps {
|
||||
nodeTypes: NodeTypesType;
|
||||
selectNodesOnDrag: boolean;
|
||||
onElementClick?: (element: Node | Edge) => void;
|
||||
onNodeDragStart?: (node: Node) => void;
|
||||
onNodeDragStop?: (node: Node) => void;
|
||||
@@ -44,6 +45,7 @@ function renderNode(
|
||||
isInteractive={isInteractive}
|
||||
sourcePosition={node.sourcePosition}
|
||||
targetPosition={node.targetPosition}
|
||||
selectNodesOnDrag={props.selectNodesOnDrag}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ export interface ReactFlowProps extends Omit<HTMLAttributes<HTMLDivElement>, 'on
|
||||
snapGrid: [number, number];
|
||||
onlyRenderVisibleNodes: boolean;
|
||||
isInteractive: boolean;
|
||||
selectNodesOnDrag: boolean;
|
||||
}
|
||||
|
||||
const ReactFlow = ({
|
||||
@@ -69,6 +70,7 @@ const ReactFlow = ({
|
||||
snapGrid,
|
||||
onlyRenderVisibleNodes,
|
||||
isInteractive,
|
||||
selectNodesOnDrag,
|
||||
}: ReactFlowProps) => {
|
||||
const nodeTypesParsed = useMemo(() => createNodeTypes(nodeTypes), []);
|
||||
const edgeTypesParsed = useMemo(() => createEdgeTypes(edgeTypes), []);
|
||||
@@ -95,6 +97,7 @@ const ReactFlow = ({
|
||||
snapGrid={snapGrid}
|
||||
onlyRenderVisibleNodes={onlyRenderVisibleNodes}
|
||||
isInteractive={isInteractive}
|
||||
selectNodesOnDrag={selectNodesOnDrag}
|
||||
/>
|
||||
{onSelectionChange && <SelectionListener onSelectionChange={onSelectionChange} />}
|
||||
{children}
|
||||
@@ -124,6 +127,7 @@ ReactFlow.defaultProps = {
|
||||
snapGrid: [16, 16],
|
||||
onlyRenderVisibleNodes: true,
|
||||
isInteractive: true,
|
||||
selectNodesOnDrag: true,
|
||||
};
|
||||
|
||||
export default ReactFlow;
|
||||
|
||||
Reference in New Issue
Block a user