refactor(internals): use non enumerable props

This commit is contained in:
moklick
2022-05-26 19:55:03 +02:00
parent 03f0be62f7
commit 27b5de2d96
8 changed files with 41 additions and 22 deletions
+4 -2
View File
@@ -6,6 +6,7 @@ import { getBezierPath } from '../Edges/BezierEdge';
import { getSmoothStepPath } from '../Edges/SmoothStepEdge';
import { ConnectionLineType, ConnectionLineComponent, HandleType, Node, ReactFlowState, Position } from '../../types';
import { getSimpleBezierPath } from '../Edges/SimpleBezierEdge';
import { handleBoundsSymbol } from '../../utils';
interface ConnectionLineProps {
connectionNodeId: string;
@@ -37,12 +38,13 @@ export default ({
const { nodeInternals, transform } = useStore(selector, shallow);
const fromNode = useRef<Node | undefined>(nodeInternals.get(nodeId));
const fromHandleBounds = fromNode.current?.[handleBoundsSymbol];
if (!fromNode.current || !isConnectable || !fromNode.current.handleBounds?.[connectionHandleType]) {
if (!fromNode.current || !isConnectable || !fromHandleBounds?.[connectionHandleType]) {
return null;
}
const handleBound = fromNode.current.handleBounds?.[connectionHandleType];
const handleBound = fromHandleBounds[connectionHandleType];
const fromHandle = handleId ? handleBound?.find((d) => d.id === handleId) : handleBound?.[0];
const fromHandleX = fromHandle ? fromHandle.x + fromHandle.width / 2 : (fromNode.current?.width ?? 0) / 2;
const fromHandleY = fromHandle ? fromHandle.y + fromHandle.height / 2 : fromNode.current?.height ?? 0;