added final connection state to onReconnectEnd
This commit is contained in:
@@ -50,10 +50,9 @@ export type OnConnectStartParams = {
|
||||
|
||||
export type OnConnectStart = (event: MouseEvent | TouchEvent, params: OnConnectStartParams) => void;
|
||||
export type OnConnect = (connection: Connection) => void;
|
||||
export type OnConnectEnd = (
|
||||
event: MouseEvent | TouchEvent,
|
||||
connectionState: Omit<ConnectionState, 'inProgress'>
|
||||
) => void;
|
||||
export type OnConnectEnd = (event: MouseEvent | TouchEvent, connectionState: FinalConnectionState) => void;
|
||||
|
||||
export type FinalConnectionState = Omit<ConnectionState, 'inProgress'>;
|
||||
|
||||
export type IsValidConnection = (edge: EdgeBase | Connection) => boolean;
|
||||
|
||||
|
||||
@@ -194,13 +194,14 @@ function onPointerDown(
|
||||
// in order to get the latest state of onConnectEnd
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { inProgress, ...connectionState } = previousConnection;
|
||||
onConnectEnd?.(event, {
|
||||
const finalConnectionState = {
|
||||
...connectionState,
|
||||
toPosition: previousConnection.toHandle ? previousConnection.toPosition : null,
|
||||
});
|
||||
};
|
||||
onConnectEnd?.(event, finalConnectionState);
|
||||
|
||||
if (edgeUpdaterType) {
|
||||
onReconnectEnd?.(event);
|
||||
onReconnectEnd?.(event, finalConnectionState);
|
||||
}
|
||||
|
||||
cancelConnection();
|
||||
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
type UpdateConnection,
|
||||
type IsValidConnection,
|
||||
NodeLookup,
|
||||
ConnectionState,
|
||||
FinalConnectionState,
|
||||
} from '../types';
|
||||
|
||||
export type OnPointerDownParams = {
|
||||
@@ -32,7 +34,7 @@ export type OnPointerDownParams = {
|
||||
onConnect?: OnConnect;
|
||||
onConnectEnd?: OnConnectEnd;
|
||||
isValidConnection?: IsValidConnection;
|
||||
onReconnectEnd?: (evt: MouseEvent | TouchEvent) => void;
|
||||
onReconnectEnd?: (evt: MouseEvent | TouchEvent, connectionState: FinalConnectionState) => void;
|
||||
getTransform: () => Transform;
|
||||
getFromHandle: () => Handle | null;
|
||||
autoPanSpeed?: number;
|
||||
|
||||
Reference in New Issue
Block a user