feat(props): add onZoomPaneClick

This commit is contained in:
Nate Amack
2020-07-31 10:45:40 -06:00
parent e3d24507e5
commit 2a0274b9a3
4 changed files with 26 additions and 2 deletions
+7 -2
View File
@@ -39,6 +39,7 @@ export interface GraphViewProps {
onMove?: (flowTransform?: FlowTransform) => void;
onMoveStart?: (flowTransform?: FlowTransform) => void;
onMoveEnd?: (flowTransform?: FlowTransform) => void;
onZoomPaneClick?: () => void;
selectionKeyCode: number;
nodeTypes: NodeTypesType;
edgeTypes: EdgeTypesType;
@@ -100,6 +101,7 @@ const GraphView = ({
zoomOnScroll,
zoomOnDoubleClick,
paneMoveable,
onZoomPaneClick,
}: GraphViewProps) => {
const zoomPane = useRef<HTMLDivElement>(null);
const rendererNode = useRef<HTMLDivElement>(null);
@@ -121,7 +123,10 @@ const GraphView = ({
const selectionKeyPressed = useKeyPress(selectionKeyCode);
const onZoomPaneClick = () => setNodesSelection({ isActive: false });
const handleZoomPaneClick = () => {
onZoomPaneClick?.();
setNodesSelection({ isActive: false });
};
const updateDimensions = () => {
if (!rendererNode.current) {
@@ -254,7 +259,7 @@ const GraphView = ({
/>
<UserSelection selectionKeyPressed={selectionKeyPressed} />
{nodesSelectionActive && <NodesSelection />}
<div className="react-flow__zoompane" onClick={onZoomPaneClick} ref={zoomPane} />
<div className="react-flow__zoompane" onClick={handleZoomPaneClick} ref={zoomPane} />
</div>
);
};