Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.

Commit 944511f

Browse files
committed
Fixed getPoint for same node edges
Signed-off-by: André Martins <[email protected]>
1 parent 6de24a2 commit 944511f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/network/modules/components/edges/BezierEdgeDynamic.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,16 @@ class BezierEdgeDynamic extends BezierEdgeBase {
133133
*/
134134
getPoint(percentage, viaNode = this.via) {
135135
let t = percentage;
136-
let x = Math.pow(1 - t, 2) * this.fromPoint.x + (2 * t * (1 - t)) * viaNode.x + Math.pow(t, 2) * this.toPoint.x;
137-
let y = Math.pow(1 - t, 2) * this.fromPoint.y + (2 * t * (1 - t)) * viaNode.y + Math.pow(t, 2) * this.toPoint.y;
136+
let x, y;
137+
if (this.from === this.to){
138+
let [cx,cy,cr] = this._getCircleData(this.from)
139+
let a = 2 * Math.PI * (1 - t);
140+
x = cx + cr * Math.sin(a);
141+
y = cy + cr - cr * (1 - Math.cos(a));
142+
} else {
143+
x = Math.pow(1 - t, 2) * this.fromPoint.x + 2 * t * (1 - t) * viaNode.x + Math.pow(t, 2) * this.toPoint.x;
144+
y = Math.pow(1 - t, 2) * this.fromPoint.y + 2 * t * (1 - t) * viaNode.y + Math.pow(t, 2) * this.toPoint.y;
145+
}
138146

139147
return {x: x, y: y};
140148
}
@@ -151,4 +159,4 @@ class BezierEdgeDynamic extends BezierEdgeBase {
151159
}
152160

153161

154-
export default BezierEdgeDynamic;
162+
export default BezierEdgeDynamic;

0 commit comments

Comments
 (0)