jsplumb / community-edition

The community edition of jsPlumb, versions 1.x - 6.x
https://jsplumbtoolkit.com
Other
225 stars 18 forks source link

Add ability to straighten bezier curves #1056

Open VincentK-ZA opened 4 months ago

VincentK-ZA commented 4 months ago

We'd like to be able to configure bezier curve connectors to make a straight line when the difference between the two anchors is negligible.

In this PR I've "hijacked" the margin param as an easy way to add this functionality, where if the difference between anchors is less than the margin, the minorAnchor offset is not added.

straight-bezier

Please let me know your thoughts on this.

It might be worthwhile exposing the minorAnchor property through the params as well.
I realize setting minorAnchor to 0 would also cause the bezier to be straight, but we would like to keep that offset when they are different.
One thought I had based on this PR is to scale the minorAnchor based on the difference between anchor points. So that if they are close together, minorAnchor goes to 0, giving straight lines.