Merge branch 'xyflow' of github.com:wbkd/react-flow into xyflow

This commit is contained in:
moklick
2023-09-27 16:11:03 +02:00
14 changed files with 198 additions and 64 deletions
+4 -4
View File
@@ -131,8 +131,8 @@ export type UpdateNodePositions = (
export type PanBy = (delta: XYPosition) => boolean;
export type UpdateConnection = (params: {
connectionPosition?: XYPosition | null;
connectionStatus?: ConnectionStatus | null;
connectionStartHandle?: ConnectingHandle | null;
connectionEndHandle?: ConnectingHandle | null;
connectionPosition: XYPosition | null;
connectionStatus: ConnectionStatus | null;
connectionStartHandle: ConnectingHandle | null;
connectionEndHandle: ConnectingHandle | null;
}) => void;
+12 -5
View File
@@ -66,6 +66,8 @@ const nullConnection: Connection = { source: null, target: null, sourceHandle: n
const alwaysValid = () => true;
let connectionStartHandle: ConnectingHandle | null = null;
function onPointerDown(
event: MouseEvent | TouchEvent,
{
@@ -129,15 +131,18 @@ function onPointerDown(
autoPanId = requestAnimationFrame(autoPan);
}
// Stays the same for all consecutive pointermove events
connectionStartHandle = {
nodeId,
handleId,
type: handleType,
};
updateConnection({
connectionPosition,
connectionStatus: null,
// connectionNodeId etc will be removed in the next major in favor of connectionStartHandle
connectionStartHandle: {
nodeId,
handleId,
type: handleType,
},
connectionStartHandle,
connectionEndHandle: null,
});
@@ -173,6 +178,7 @@ function onPointerDown(
isValid = result.isValid;
updateConnection({
connectionStartHandle,
connectionPosition:
closestHandle && isValid
? rendererPointToPoint(
@@ -220,6 +226,7 @@ function onPointerDown(
isValid = false;
connection = null;
handleDomNode = null;
connectionStartHandle = null;
doc.removeEventListener('mousemove', onPointerMove as EventListener);
doc.removeEventListener('mouseup', onPointerUp as EventListener);