Files
vue-flow/examples/Edges/CustomEdge.tsx
T
Braks 2188c5d3d3 feat(example): Add custom edge example
update(example): fit view on custom node example
* node selection to use hooks
* dev script to use vue-tsc
2021-08-08 19:28:45 +02:00

32 lines
797 B
TypeScript

import { EdgeProps, getBezierPath, getMarkerEnd } from '../../src';
import { FunctionalComponent } from 'vue';
const CustomEdge: FunctionalComponent<EdgeProps> = ({
id,
sourceX,
sourceY,
targetX,
targetY,
sourcePosition,
targetPosition,
data,
arrowHeadType,
markerEndId
}) => {
const edgePath = getBezierPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition });
const markerEnd = getMarkerEnd(arrowHeadType, markerEndId);
return () => (
<>
<path id={id} class="react-flow__edge-path" d={edgePath} marker-end={markerEnd} />
<text>
<textPath href={`#${id}`} style={{ fontSize: '12px' }} startOffset="50%" text-anchor="middle">
{data.text}
</textPath>
</text>
</>
);
};
export default CustomEdge;