A ReactFlow Bezier Edge but with Offset
npm install reactflow-better-bezier-edge   
Are you suffering the default bezier curve goes into your marker?
If so, this is the solution for you.
All credits go to reactflow for the bezier curve calculation. I just made modifications to the original code to make it better.
Give me a ⭐ if you like it.
- ReactFlow >= 11.0.0
``bash`
npm install reactflow-better-bezier-edge
`tsx
import { Position } from "reactflow";
import { getBetterBezierPath } from "reactflow-better-bezier-edge";
const [path, labelX, labelY, offsetX, offsetY] = getBetterBezierPath({
sourceX: source.x,
sourceY: source.y,
sourcePosition: Position.Right,
targetX: target.x,
targetY: target.y,
targetPosition: Position.Left,
offset: 70,
});
`
The parameters for the bezier curve.
| Prop | Optional | Type | Default | Description |
| --- | --- | --- | --- | --- |
|sourceX|No|number| |The x-coordinate of the source node.|
|sourceY|No|number| |The y-coordinate of the source node.|
|sourcePosition|Yes|Position|Position.Bottom|The position of the source node.|
|targetX|No|number| |The x-coordinate of the target node.|
|targetY|No|number| |The y-coordinate of the target node.|
|targetPosition|Yes|Position|Position.Top|The position of the target node.|
|offset|Yes|number|0|The offset of the bezier curve.|
> [NOTE]\
> Play around with the offset` to get the best result.
You can reference to BezierEdge for more information.
Contributions are welcome! If you find a bug , please open an issue. If you want to contribute code, please fork the repository and submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details
Love it? Consider a donation to support my work.
 <- click me~