Change boolean 'isSourceHandle' parameter to handleType: HandleType in 'onEdgeUpdateStart' function

- In order to make the function better extendable in the future.
This commit is contained in:
Andreas Schultz
2022-04-04 09:53:19 +02:00
parent e8aa8737ae
commit 68ec5d87d7
4 changed files with 8 additions and 5 deletions
+3 -2
View File
@@ -137,10 +137,11 @@ export default (EdgeComponent: ComponentType<EdgeProps>) => {
(event: React.MouseEvent<SVGGElement, MouseEvent>, isSourceHandle: boolean) => {
const nodeId = isSourceHandle ? target : source;
const handleId = isSourceHandle ? targetHandleId : sourceHandleId;
const handleType = isSourceHandle ? 'target' : 'source'
const isValidConnection = () => true;
const isTarget = isSourceHandle;
onEdgeUpdateStart?.(event, edgeElement, isSourceHandle);
onEdgeUpdateStart?.(event, edgeElement, handleType);
const _onEdgeUpdate = onEdgeUpdateEnd
? (evt: MouseEvent): void => onEdgeUpdateEnd(evt, edgeElement)
@@ -156,7 +157,7 @@ export default (EdgeComponent: ComponentType<EdgeProps>) => {
isTarget,
isValidConnection,
connectionMode,
isSourceHandle ? 'target' : 'source',
handleType,
_onEdgeUpdate
);
},
+2 -1
View File
@@ -16,6 +16,7 @@ import {
ConnectionMode,
Transform,
OnEdgeUpdateFunc,
HandleType,
} from '../../types';
interface EdgeRendererProps {
@@ -34,7 +35,7 @@ interface EdgeRendererProps {
onEdgeMouseEnter?: (event: React.MouseEvent, edge: Edge) => void;
onEdgeMouseMove?: (event: React.MouseEvent, edge: Edge) => void;
onEdgeMouseLeave?: (event: React.MouseEvent, edge: Edge) => void;
onEdgeUpdateStart?: (event: React.MouseEvent, edge: Edge, isSourceHandle: boolean) => void;
onEdgeUpdateStart?: (event: React.MouseEvent, edge: Edge, handleType: HandleType) => void;
onEdgeUpdateEnd?: (event: MouseEvent, edge: Edge) => void;
edgeUpdaterRadius?: number;
}
+2 -1
View File
@@ -38,6 +38,7 @@ import {
PanOnScrollMode,
OnEdgeUpdateFunc,
NodeExtent,
HandleType,
} from '../../types';
import '../../style.css';
@@ -123,7 +124,7 @@ export interface ReactFlowProps extends Omit<HTMLAttributes<HTMLDivElement>, 'on
onEdgeMouseMove?: (event: ReactMouseEvent, edge: Edge) => void;
onEdgeMouseLeave?: (event: ReactMouseEvent, edge: Edge) => void;
onEdgeDoubleClick?: (event: ReactMouseEvent, edge: Edge) => void;
onEdgeUpdateStart?: (event: ReactMouseEvent, edge: Edge, isSourceHandle: boolean) => void;
onEdgeUpdateStart?: (event: ReactMouseEvent, edge: Edge, handleType: HandleType) => void;
onEdgeUpdateEnd?: (event: MouseEvent, edge: Edge) => void;
edgeUpdaterRadius?: number;
nodeTypesId?: string;
+1 -1
View File
@@ -132,7 +132,7 @@ export interface WrapEdgeProps<T = any> {
onMouseMove?: (event: React.MouseEvent, edge: Edge) => void;
onMouseLeave?: (event: React.MouseEvent, edge: Edge) => void;
edgeUpdaterRadius?: number;
onEdgeUpdateStart?: (event: React.MouseEvent, edge: Edge, isSourceHandle: boolean) => void;
onEdgeUpdateStart?: (event: React.MouseEvent, edge: Edge, handleType: HandleType) => void;
onEdgeUpdateEnd?: (event: MouseEvent, edge: Edge) => void;
}