Revert "Merge pull request #1003 from TheUnderScorer/main"
This reverts commit106f1f0b61, reversing changes made to9206e65522.
This commit is contained in:
@@ -11,7 +11,6 @@ import {
|
||||
SetConnectionId,
|
||||
Connection,
|
||||
} from '../../types';
|
||||
import { getInitialDocument } from '../../utils/document';
|
||||
|
||||
type ValidConnectionFunc = (connection: Connection) => boolean;
|
||||
export type SetSourceIdFunc = (params: SetConnectionId) => void;
|
||||
@@ -32,8 +31,7 @@ function checkElementBelowIsValid(
|
||||
isTarget: boolean,
|
||||
nodeId: ElementId,
|
||||
handleId: ElementId | null,
|
||||
isValidConnection: ValidConnectionFunc,
|
||||
document: Document | ShadowRoot
|
||||
isValidConnection: ValidConnectionFunc
|
||||
) {
|
||||
const elementBelow = document.elementFromPoint(event.clientX, event.clientY);
|
||||
const elementBelowIsTarget = elementBelow?.classList.contains('target') || false;
|
||||
@@ -97,13 +95,8 @@ export function onMouseDown(
|
||||
connectionMode: ConnectionMode,
|
||||
onConnectStart?: OnConnectStartFunc,
|
||||
onConnectStop?: OnConnectStopFunc,
|
||||
onConnectEnd?: OnConnectEndFunc,
|
||||
document: Document | ShadowRoot | undefined = getInitialDocument()
|
||||
onConnectEnd?: OnConnectEndFunc
|
||||
): void {
|
||||
if(!document) {
|
||||
return;
|
||||
}
|
||||
|
||||
const reactFlowNode = (event.target as Element).closest('.react-flow');
|
||||
const elementBelow = document.elementFromPoint(event.clientX, event.clientY);
|
||||
const elementBelowIsTarget = elementBelow?.classList.contains('target');
|
||||
@@ -126,7 +119,7 @@ export function onMouseDown(
|
||||
setConnectionNodeId({ connectionNodeId: nodeId, connectionHandleId: handleId, connectionHandleType: handleType });
|
||||
onConnectStart?.(event, { nodeId, handleId, handleType });
|
||||
|
||||
const onMouseMove = (event: MouseEvent) => {
|
||||
function onMouseMove(event: MouseEvent) {
|
||||
setPosition({
|
||||
x: event.clientX - containerBounds.left,
|
||||
y: event.clientY - containerBounds.top,
|
||||
@@ -138,8 +131,7 @@ export function onMouseDown(
|
||||
isTarget,
|
||||
nodeId,
|
||||
handleId,
|
||||
isValidConnection,
|
||||
document
|
||||
isValidConnection
|
||||
);
|
||||
|
||||
if (!isHoveringHandle) {
|
||||
@@ -153,17 +145,16 @@ export function onMouseDown(
|
||||
elementBelow.classList.add('react-flow__handle-connecting');
|
||||
elementBelow.classList.toggle('react-flow__handle-valid', isValid);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const onMouseUp = (event: MouseEvent) => {
|
||||
function onMouseUp(event: MouseEvent) {
|
||||
const { connection, isValid } = checkElementBelowIsValid(
|
||||
event,
|
||||
connectionMode,
|
||||
isTarget,
|
||||
nodeId,
|
||||
handleId,
|
||||
isValidConnection,
|
||||
document
|
||||
isValidConnection
|
||||
);
|
||||
|
||||
onConnectStop?.(event);
|
||||
@@ -177,10 +168,10 @@ export function onMouseDown(
|
||||
resetRecentHandle(recentHoveredHandle);
|
||||
setConnectionNodeId({ connectionNodeId: null, connectionHandleId: null, connectionHandleType: null });
|
||||
|
||||
document.removeEventListener('mousemove', onMouseMove as EventListenerOrEventListenerObject);
|
||||
document.removeEventListener('mouseup', onMouseUp as EventListenerOrEventListenerObject);
|
||||
};
|
||||
document.removeEventListener('mousemove', onMouseMove);
|
||||
document.removeEventListener('mouseup', onMouseUp);
|
||||
}
|
||||
|
||||
document.addEventListener('mousemove', onMouseMove as EventListenerOrEventListenerObject);
|
||||
document.addEventListener('mouseup', onMouseUp as EventListenerOrEventListenerObject);
|
||||
document.addEventListener('mousemove', onMouseMove);
|
||||
document.addEventListener('mouseup', onMouseUp);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ const Handle: FC<HandleProps & Omit<HTMLAttributes<HTMLDivElement>, 'id'>> = ({
|
||||
const onConnectStop = useStoreState((state) => state.onConnectStop);
|
||||
const onConnectEnd = useStoreState((state) => state.onConnectEnd);
|
||||
const connectionMode = useStoreState((state) => state.connectionMode);
|
||||
const document = useStoreState(state => state.document);
|
||||
const handleId = id || null;
|
||||
const isTarget = type === 'target';
|
||||
|
||||
@@ -54,8 +53,7 @@ const Handle: FC<HandleProps & Omit<HTMLAttributes<HTMLDivElement>, 'id'>> = ({
|
||||
connectionMode,
|
||||
onConnectStart,
|
||||
onConnectStop,
|
||||
onConnectEnd,
|
||||
document
|
||||
onConnectEnd
|
||||
);
|
||||
},
|
||||
[
|
||||
@@ -70,7 +68,6 @@ const Handle: FC<HandleProps & Omit<HTMLAttributes<HTMLDivElement>, 'id'>> = ({
|
||||
onConnectStart,
|
||||
onConnectStop,
|
||||
onConnectEnd,
|
||||
document
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user