refactor(drag-edge): only handle when update function is passed

This commit is contained in:
moklick
2020-11-26 15:17:31 +01:00
parent 2f40a83b47
commit d17562e1a1
5 changed files with 52 additions and 6376 deletions
+7
View File
@@ -15,6 +15,7 @@ import {
ConnectionLineType,
ConnectionLineComponent,
OnEdgeUpdateFunc,
Connection,
} from '../../types';
interface EdgeRendererProps {
@@ -188,6 +189,10 @@ function renderEdge(
const isSelected = selectedElements ? selectedElements.some((elm) => isEdge(elm) && elm.id === edge.id) : false;
const onConnectEdge = (connection: Connection) => {
props.onEdgeUpdate?.(edge, connection);
};
return (
<EdgeComponent
key={edge.id}
@@ -219,6 +224,8 @@ function renderEdge(
elementsSelectable={elementsSelectable}
markerEndId={props.markerEndId}
isHidden={edge.isHidden}
onConnectEdge={onConnectEdge}
handleEdgeUpdate={typeof props.onEdgeUpdate !== 'undefined'}
/>
);
}