feat(props): add onEdgeUpdateEnd handler closes #1157

This commit is contained in:
moklick
2021-05-29 15:12:31 +02:00
parent f244e77b9e
commit 27e2781d8c
8 changed files with 54 additions and 25 deletions
+7 -1
View File
@@ -45,6 +45,7 @@ export default (EdgeComponent: ComponentType<EdgeProps>) => {
onMouseLeave,
edgeUpdaterRadius,
onEdgeUpdateStart,
onEdgeUpdateEnd,
}: WrapEdgeProps): JSX.Element | null => {
const addSelectedElements = useStoreActions((actions) => actions.addSelectedElements);
const setConnectionNodeId = useStoreActions((actions) => actions.setConnectionNodeId);
@@ -141,6 +142,10 @@ export default (EdgeComponent: ComponentType<EdgeProps>) => {
onEdgeUpdateStart?.(event, edgeElement);
const _onEdgeUpdate = onEdgeUpdateEnd
? (evt: MouseEvent): void => onEdgeUpdateEnd(evt, edgeElement)
: undefined;
onMouseDown(
event,
handleId,
@@ -151,7 +156,8 @@ export default (EdgeComponent: ComponentType<EdgeProps>) => {
isTarget,
isValidConnection,
connectionMode,
isSourceHandle ? 'target' : 'source'
isSourceHandle ? 'target' : 'source',
_onEdgeUpdate
);
},
[id, source, target, type, sourceHandleId, targetHandleId, setConnectionNodeId, setPosition, edgeElement]
+6 -1
View File
@@ -97,7 +97,8 @@ export function onMouseDown(
isTarget: boolean,
isValidConnection: ValidConnectionFunc,
connectionMode: ConnectionMode,
elementEdgeUpdaterType?: HandleType | null,
elementEdgeUpdaterType?: HandleType,
onEdgeUpdateEnd?: (evt: MouseEvent) => void,
onConnectStart?: OnConnectStartFunc,
onConnectStop?: OnConnectStopFunc,
onConnectEnd?: OnConnectEndFunc
@@ -178,6 +179,10 @@ export function onMouseDown(
onConnectEnd?.(event);
if (elementEdgeUpdaterType && onEdgeUpdateEnd) {
onEdgeUpdateEnd(event);
}
resetRecentHandle(recentHoveredHandle);
setConnectionNodeId({ connectionNodeId: null, connectionHandleId: null, connectionHandleType: null });
+2 -1
View File
@@ -51,7 +51,8 @@ const Handle: FC<HandleProps & Omit<HTMLAttributes<HTMLDivElement>, 'id'>> = ({
isTarget,
isValidConnection,
connectionMode,
null,
undefined,
undefined,
onConnectStart,
onConnectStop,
onConnectEnd