I'm trying to expand the Connected Objects demo by allowing two nodes (shapes of Circle
class) to be double referenced (A connects to B with Arrow1
and B connects to A with Arrow2
). I work with react-konva
package.
I have implemented a demo on Code Sandbox with some basic functionality.
On line 5
, 6
you'll find the Nodes info, on line 21
there exists a high-order component that creates the Arrow based on the start Node and end Node position.
In the default example, the arrows are working as expected. If you try to set the value of redNode.x
to 300
the arrows overlap. The same happens when blueNode.x
is equal to -100
. This has something to do with the way I calculate the arrows (I suspect the equations on line 38
).
Also note that as redNode.x
moves to value 300
, the two arrows approach each other (this happens on other values too), which is something I do not want to happen. I expect the arrows to have the same shape when the two nodes change position and not to overlap or approach each other. Unfortunately, my lack of mathematics does not help me solve the problem. I also tried to create a custom shape using quadraticCurveTo
method without success.
Thanks in advance for the help. I appreciate all the solutions.