Spaces:
Running
Running
Download src/features/canvas/components/SmartEdge.jsx from DanilDrotik/FlowWeb: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/spaces/DanilDrotik/FlowWeb/resolve/main/src/features/canvas/components/SmartEdge.jsx
- Command line
-
hf download hf://spaces/DanilDrotik/FlowWeb/src/features/canvas/components/SmartEdge.jsx
-
curl -L -o SmartEdge.jsx https://huggingface.co/spaces/DanilDrotik/FlowWeb/resolve/main/src/features/canvas/components/SmartEdge.jsx
1.37 kB
| import React from 'react'; | |
| import { BaseEdge, getBezierPath, useInternalNode } from '@xyflow/react'; | |
| import { floatingPoints, isMeaningfulHandle } from './floatingEdge'; | |
| // Default edge: floats between the facing sides of its nodes; a condition keeps its branch handle. | |
| export default function SmartEdge({ | |
| id, | |
| source, | |
| target, | |
| sourceHandleId, | |
| sourceX, | |
| sourceY, | |
| targetX, | |
| targetY, | |
| sourcePosition, | |
| targetPosition, | |
| markerEnd, | |
| style, | |
| interactionWidth, | |
| }) { | |
| const sourceNode = useInternalNode(source); | |
| const targetNode = useInternalNode(target); | |
| let points = { sx: sourceX, sy: sourceY, tx: targetX, ty: targetY, sourcePos: sourcePosition, targetPos: targetPosition }; | |
| if (sourceNode && targetNode) { | |
| points = floatingPoints(sourceNode, targetNode, { | |
| keepSource: isMeaningfulHandle(sourceNode, sourceHandleId) || sourceNode.type === 'portal', | |
| keepTarget: targetNode.type === 'portal', | |
| sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, | |
| }); | |
| } | |
| const [path] = getBezierPath({ | |
| sourceX: points.sx, | |
| sourceY: points.sy, | |
| sourcePosition: points.sourcePos, | |
| targetX: points.tx, | |
| targetY: points.ty, | |
| targetPosition: points.targetPos, | |
| curvature: 0.3, | |
| }); | |
| return <BaseEdge id={id} path={path} markerEnd={markerEnd} style={style} interactionWidth={interactionWidth} />; | |
| } | |