feat(nodes): add selectNodesOnDrag prop type

This commit is contained in:
moklick
2020-05-25 18:13:12 +02:00
parent b6b3fded77
commit 02b4dc82df
7 changed files with 47 additions and 9 deletions
+3
View File
@@ -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}
+2
View File
@@ -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}
/>
);
}
+4
View File
@@ -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;