feat(rf): add fitViewOnInit option

This commit is contained in:
moklick
2021-12-08 23:19:43 +01:00
parent 91256c1f92
commit 266007b38b
2 changed files with 55 additions and 1 deletions
+4 -1
View File
@@ -19,6 +19,7 @@ import SelectionListener from '../../components/SelectionListener';
import { BezierEdge, StepEdge, SmoothStepEdge, StraightEdge } from '../../components/Edges';
import { createEdgeTypes } from '../EdgeRenderer/utils';
import Wrapper from './Wrapper';
import ViewFitter from '../../components/ViewFitter';
import {
OnSelectionChangeFunc,
NodeTypesType,
@@ -133,6 +134,7 @@ export interface ReactFlowProps extends Omit<HTMLAttributes<HTMLDivElement>, 'on
noDragClassName?: string;
noWheelClassName?: string;
noPanClassName?: string;
fitViewOnInit?: boolean;
}
export type ReactFlowRefType = HTMLDivElement;
@@ -219,6 +221,7 @@ const ReactFlow: FunctionComponent<ReactFlowProps> = forwardRef<ReactFlowRefType
noDragClassName = 'nodrag',
noWheelClassName = 'nowheel',
noPanClassName = 'nopan',
fitViewOnInit = false,
...rest
},
ref
@@ -307,7 +310,7 @@ const ReactFlow: FunctionComponent<ReactFlowProps> = forwardRef<ReactFlowRefType
connectionMode={connectionMode}
translateExtent={translateExtent}
/>
{fitViewOnInit && <ViewFitter nodes={nodes} />}
{onSelectionChange && <SelectionListener onSelectionChange={onSelectionChange} />}
{children}
</Wrapper>