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:
@@ -137,10 +137,11 @@ export default (EdgeComponent: ComponentType<EdgeProps>) => {
|
|||||||
(event: React.MouseEvent<SVGGElement, MouseEvent>, isSourceHandle: boolean) => {
|
(event: React.MouseEvent<SVGGElement, MouseEvent>, isSourceHandle: boolean) => {
|
||||||
const nodeId = isSourceHandle ? target : source;
|
const nodeId = isSourceHandle ? target : source;
|
||||||
const handleId = isSourceHandle ? targetHandleId : sourceHandleId;
|
const handleId = isSourceHandle ? targetHandleId : sourceHandleId;
|
||||||
|
const handleType = isSourceHandle ? 'target' : 'source'
|
||||||
const isValidConnection = () => true;
|
const isValidConnection = () => true;
|
||||||
const isTarget = isSourceHandle;
|
const isTarget = isSourceHandle;
|
||||||
|
|
||||||
onEdgeUpdateStart?.(event, edgeElement, isSourceHandle);
|
onEdgeUpdateStart?.(event, edgeElement, handleType);
|
||||||
|
|
||||||
const _onEdgeUpdate = onEdgeUpdateEnd
|
const _onEdgeUpdate = onEdgeUpdateEnd
|
||||||
? (evt: MouseEvent): void => onEdgeUpdateEnd(evt, edgeElement)
|
? (evt: MouseEvent): void => onEdgeUpdateEnd(evt, edgeElement)
|
||||||
@@ -156,7 +157,7 @@ export default (EdgeComponent: ComponentType<EdgeProps>) => {
|
|||||||
isTarget,
|
isTarget,
|
||||||
isValidConnection,
|
isValidConnection,
|
||||||
connectionMode,
|
connectionMode,
|
||||||
isSourceHandle ? 'target' : 'source',
|
handleType,
|
||||||
_onEdgeUpdate
|
_onEdgeUpdate
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
ConnectionMode,
|
ConnectionMode,
|
||||||
Transform,
|
Transform,
|
||||||
OnEdgeUpdateFunc,
|
OnEdgeUpdateFunc,
|
||||||
|
HandleType,
|
||||||
} from '../../types';
|
} from '../../types';
|
||||||
|
|
||||||
interface EdgeRendererProps {
|
interface EdgeRendererProps {
|
||||||
@@ -34,7 +35,7 @@ interface EdgeRendererProps {
|
|||||||
onEdgeMouseEnter?: (event: React.MouseEvent, edge: Edge) => void;
|
onEdgeMouseEnter?: (event: React.MouseEvent, edge: Edge) => void;
|
||||||
onEdgeMouseMove?: (event: React.MouseEvent, edge: Edge) => void;
|
onEdgeMouseMove?: (event: React.MouseEvent, edge: Edge) => void;
|
||||||
onEdgeMouseLeave?: (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;
|
onEdgeUpdateEnd?: (event: MouseEvent, edge: Edge) => void;
|
||||||
edgeUpdaterRadius?: number;
|
edgeUpdaterRadius?: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import {
|
|||||||
PanOnScrollMode,
|
PanOnScrollMode,
|
||||||
OnEdgeUpdateFunc,
|
OnEdgeUpdateFunc,
|
||||||
NodeExtent,
|
NodeExtent,
|
||||||
|
HandleType,
|
||||||
} from '../../types';
|
} from '../../types';
|
||||||
|
|
||||||
import '../../style.css';
|
import '../../style.css';
|
||||||
@@ -123,7 +124,7 @@ export interface ReactFlowProps extends Omit<HTMLAttributes<HTMLDivElement>, 'on
|
|||||||
onEdgeMouseMove?: (event: ReactMouseEvent, edge: Edge) => void;
|
onEdgeMouseMove?: (event: ReactMouseEvent, edge: Edge) => void;
|
||||||
onEdgeMouseLeave?: (event: ReactMouseEvent, edge: Edge) => void;
|
onEdgeMouseLeave?: (event: ReactMouseEvent, edge: Edge) => void;
|
||||||
onEdgeDoubleClick?: (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;
|
onEdgeUpdateEnd?: (event: MouseEvent, edge: Edge) => void;
|
||||||
edgeUpdaterRadius?: number;
|
edgeUpdaterRadius?: number;
|
||||||
nodeTypesId?: string;
|
nodeTypesId?: string;
|
||||||
|
|||||||
+1
-1
@@ -132,7 +132,7 @@ export interface WrapEdgeProps<T = any> {
|
|||||||
onMouseMove?: (event: React.MouseEvent, edge: Edge) => void;
|
onMouseMove?: (event: React.MouseEvent, edge: Edge) => void;
|
||||||
onMouseLeave?: (event: React.MouseEvent, edge: Edge) => void;
|
onMouseLeave?: (event: React.MouseEvent, edge: Edge) => void;
|
||||||
edgeUpdaterRadius?: number;
|
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;
|
onEdgeUpdateEnd?: (event: MouseEvent, edge: Edge) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user