refactor(paneClick): rename onZoomPaneClick tp onPaneClick
This commit is contained in:
@@ -93,7 +93,7 @@ const BasicFlow = () => <ReactFlow elements={elements} />;
|
|||||||
- `onMoveStart()`: called when user starts panning or zooming
|
- `onMoveStart()`: called when user starts panning or zooming
|
||||||
- `onMoveEnd()`: called when user ends panning or zooming
|
- `onMoveEnd()`: called when user ends panning or zooming
|
||||||
- `onSelectionChange(elements: Elements)`: called when user selects one or multiple elements
|
- `onSelectionChange(elements: Elements)`: called when user selects one or multiple elements
|
||||||
- `onZoomPaneClick()`: called when user clicks directly on the canvas
|
- `onPaneClick()`: called when user clicks directly on the canvas
|
||||||
|
|
||||||
#### Interaction
|
#### Interaction
|
||||||
- `nodesDraggable`: default: `true`. This applies to all nodes. You can also change the behavior of a specific node with the `draggable` node option.
|
- `nodesDraggable`: default: `true`. This applies to all nodes. You can also change the behavior of a specific node with the `draggable` node option.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const initialElements = [
|
|||||||
const onNodeDragStart = (node) => console.log('drag start', node);
|
const onNodeDragStart = (node) => console.log('drag start', node);
|
||||||
const onNodeDragStop = (node) => console.log('drag stop', node);
|
const onNodeDragStop = (node) => console.log('drag stop', node);
|
||||||
const onElementClick = (element) => console.log('click', element);
|
const onElementClick = (element) => console.log('click', element);
|
||||||
const onZoomPaneClick = () => console.log('onZoomPaneClick');
|
const onPaneClick = () => console.log('onPaneClick');
|
||||||
|
|
||||||
const InteractionFlow = () => {
|
const InteractionFlow = () => {
|
||||||
const [elements, setElements] = useState(initialElements);
|
const [elements, setElements] = useState(initialElements);
|
||||||
@@ -41,7 +41,7 @@ const InteractionFlow = () => {
|
|||||||
onNodeDragStart={onNodeDragStart}
|
onNodeDragStart={onNodeDragStart}
|
||||||
onNodeDragStop={onNodeDragStop}
|
onNodeDragStop={onNodeDragStop}
|
||||||
paneMoveable={paneMoveable}
|
paneMoveable={paneMoveable}
|
||||||
onZoomPaneClick={captureZoomClick ? onZoomPaneClick : undefined}
|
onPaneClick={captureZoomClick ? onPaneClick : undefined}
|
||||||
>
|
>
|
||||||
<MiniMap />
|
<MiniMap />
|
||||||
<Controls />
|
<Controls />
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export interface GraphViewProps {
|
|||||||
onMove?: (flowTransform?: FlowTransform) => void;
|
onMove?: (flowTransform?: FlowTransform) => void;
|
||||||
onMoveStart?: (flowTransform?: FlowTransform) => void;
|
onMoveStart?: (flowTransform?: FlowTransform) => void;
|
||||||
onMoveEnd?: (flowTransform?: FlowTransform) => void;
|
onMoveEnd?: (flowTransform?: FlowTransform) => void;
|
||||||
onZoomPaneClick?: () => void;
|
onPaneClick?: () => void;
|
||||||
selectionKeyCode: number;
|
selectionKeyCode: number;
|
||||||
nodeTypes: NodeTypesType;
|
nodeTypes: NodeTypesType;
|
||||||
edgeTypes: EdgeTypesType;
|
edgeTypes: EdgeTypesType;
|
||||||
@@ -101,7 +101,7 @@ const GraphView = ({
|
|||||||
zoomOnScroll,
|
zoomOnScroll,
|
||||||
zoomOnDoubleClick,
|
zoomOnDoubleClick,
|
||||||
paneMoveable,
|
paneMoveable,
|
||||||
onZoomPaneClick,
|
onPaneClick,
|
||||||
}: GraphViewProps) => {
|
}: GraphViewProps) => {
|
||||||
const zoomPane = useRef<HTMLDivElement>(null);
|
const zoomPane = useRef<HTMLDivElement>(null);
|
||||||
const rendererNode = useRef<HTMLDivElement>(null);
|
const rendererNode = useRef<HTMLDivElement>(null);
|
||||||
@@ -123,8 +123,8 @@ const GraphView = ({
|
|||||||
|
|
||||||
const selectionKeyPressed = useKeyPress(selectionKeyCode);
|
const selectionKeyPressed = useKeyPress(selectionKeyCode);
|
||||||
|
|
||||||
const handleZoomPaneClick = () => {
|
const onZoomPaneClick = () => {
|
||||||
onZoomPaneClick?.();
|
onPaneClick?.();
|
||||||
setNodesSelection({ isActive: false });
|
setNodesSelection({ isActive: false });
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -259,7 +259,7 @@ const GraphView = ({
|
|||||||
/>
|
/>
|
||||||
<UserSelection selectionKeyPressed={selectionKeyPressed} />
|
<UserSelection selectionKeyPressed={selectionKeyPressed} />
|
||||||
{nodesSelectionActive && <NodesSelection />}
|
{nodesSelectionActive && <NodesSelection />}
|
||||||
<div className="react-flow__zoompane" onClick={handleZoomPaneClick} ref={zoomPane} />
|
<div className="react-flow__zoompane" onClick={onZoomPaneClick} ref={zoomPane} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export interface ReactFlowProps extends Omit<HTMLAttributes<HTMLDivElement>, 'on
|
|||||||
onMoveStart?: (flowTransform?: FlowTransform) => void;
|
onMoveStart?: (flowTransform?: FlowTransform) => void;
|
||||||
onMoveEnd?: (flowTransform?: FlowTransform) => void;
|
onMoveEnd?: (flowTransform?: FlowTransform) => void;
|
||||||
onSelectionChange?: (elements: Elements | null) => void;
|
onSelectionChange?: (elements: Elements | null) => void;
|
||||||
onZoomPaneClick?: () => void;
|
onPaneClick?: () => void;
|
||||||
nodeTypes: NodeTypesType;
|
nodeTypes: NodeTypesType;
|
||||||
edgeTypes: EdgeTypesType;
|
edgeTypes: EdgeTypesType;
|
||||||
connectionLineType: ConnectionLineType;
|
connectionLineType: ConnectionLineType;
|
||||||
@@ -113,7 +113,7 @@ const ReactFlow = ({
|
|||||||
zoomOnScroll,
|
zoomOnScroll,
|
||||||
zoomOnDoubleClick,
|
zoomOnDoubleClick,
|
||||||
paneMoveable,
|
paneMoveable,
|
||||||
onZoomPaneClick,
|
onPaneClick,
|
||||||
}: ReactFlowProps) => {
|
}: ReactFlowProps) => {
|
||||||
const nodeTypesParsed = useMemo(() => createNodeTypes(nodeTypes), []);
|
const nodeTypesParsed = useMemo(() => createNodeTypes(nodeTypes), []);
|
||||||
const edgeTypesParsed = useMemo(() => createEdgeTypes(edgeTypes), []);
|
const edgeTypesParsed = useMemo(() => createEdgeTypes(edgeTypes), []);
|
||||||
@@ -159,7 +159,7 @@ const ReactFlow = ({
|
|||||||
zoomOnScroll={zoomOnScroll}
|
zoomOnScroll={zoomOnScroll}
|
||||||
zoomOnDoubleClick={zoomOnDoubleClick}
|
zoomOnDoubleClick={zoomOnDoubleClick}
|
||||||
paneMoveable={paneMoveable}
|
paneMoveable={paneMoveable}
|
||||||
onZoomPaneClick={onZoomPaneClick}
|
onPaneClick={onPaneClick}
|
||||||
/>
|
/>
|
||||||
{onSelectionChange && <SelectionListener onSelectionChange={onSelectionChange} />}
|
{onSelectionChange && <SelectionListener onSelectionChange={onSelectionChange} />}
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
Reference in New Issue
Block a user