Skip to content

Commit

Permalink
fix(arrows): position self ref arrows to two different spots (#402)
Browse files Browse the repository at this point in the history
Prior to this they could've been positioned on top of one another in some cases.
  • Loading branch information
piratuks authored Jan 31, 2020
1 parent df06911 commit f0ef643
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions lib/network/modules/components/edges/util/edge-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,9 @@ export abstract class EdgeBase<Via = undefined> implements EdgeType {
if (!this.options.selfReference.renderBehindTheNode) {
//render only parts which are not overlaping with parent node
//need to find x,y of from point and x,y to point
//calculating radiangs
const low = this.options.selfReference.angle - 2 * Math.PI;
const high = this.options.selfReference.angle;
//calculating radians
const low = this.options.selfReference.angle;
const high = this.options.selfReference.angle + Math.PI;
const pointTFrom = this._findBorderPositionCircle(this.from, ctx, {
x,
y,
Expand Down Expand Up @@ -774,8 +774,8 @@ export abstract class EdgeBase<Via = undefined> implements EdgeType {
const [x, y, radius] = this._getCircleData(ctx);

if (position === "from") {
const low = this.options.selfReference.angle - 2 * Math.PI;
const high = this.options.selfReference.angle;
const low = this.options.selfReference.angle;
const high = this.options.selfReference.angle + Math.PI;

const pointT = this._findBorderPositionCircle(this.from, ctx, {
x,
Expand All @@ -787,8 +787,8 @@ export abstract class EdgeBase<Via = undefined> implements EdgeType {
angle = pointT.t * -2 * Math.PI + 1.5 * Math.PI + 0.1 * Math.PI;
arrowPoint = pointT;
} else if (position === "to") {
const low = this.options.selfReference.angle - 2 * Math.PI;
const high = this.options.selfReference.angle;
const low = this.options.selfReference.angle;
const high = this.options.selfReference.angle + Math.PI;

const pointT = this._findBorderPositionCircle(this.from, ctx, {
x,
Expand Down
24 changes: 12 additions & 12 deletions test/edges/cubic-bezier-edge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,16 +567,16 @@ describe('CubicBezierEdge', function(): void {
},
position: 'from',
expected: {
angle: 1.9037437282114893,
angle: -16.968019374652727,
core: {
x: 396.26792442306333,
y: -871.0373387250717,
x: 395.6684709042148,
y: -870.9478000797577,
},
length: 31.5,
point: {
t: 0.4970097752749478,
x: 387.0022943938739,
y: -844.2442313994518,
t: 3.5005441579550327,
x: 387.0000759840845,
y: -843.9555524981157,
},
type: 'arrow',
},
Expand Down Expand Up @@ -616,16 +616,16 @@ describe('CubicBezierEdge', function(): void {
},
position: 'to',
expected: {
angle: 13.863514558139903,
angle: -11.292410721980435,
core: {
x: 404.23324559789233,
y: -874.6679591046823,
x: 403.521164116054,
y: -874.757852447893,
},
length: 36,
point: {
t: -2.006446870554419,
x: 412.9893362093595,
y: -843.4735545230305,
t: 1.997242985827105,
x: 412.9980495257085,
y: -843.7748144604348,
},
type: 'circle',
},
Expand Down

0 comments on commit f0ef643

Please sign in to comment.