Skip to content

Commit

Permalink
fix incorrect arrow head placement on vertical arrows
Browse files Browse the repository at this point in the history
fixes #146
  • Loading branch information
ailon committed Apr 25, 2023
1 parent a765e15 commit cefeb3d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/markers/arrow-marker/ArrowMarker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,18 @@ export class ArrowMarker extends LineMarker {
['fill', this.strokeColor]
]);

let lineAngle1 = 0;
if (Math.abs(this.x1 - this.x2) > 0.1) {
const lineAngle1 =
lineAngle1 =
(Math.atan((this.y2 - this.y1) / (this.x2 - this.x1)) * 180) / Math.PI + 90 * Math.sign(this.x1 - this.x2);

const a1transform = this.arrow1.transform.baseVal.getItem(0);
a1transform.setRotate(lineAngle1, this.x1, this.y1);
this.arrow1.transform.baseVal.replaceItem(a1transform, 0);

const a2transform = this.arrow2.transform.baseVal.getItem(0);
a2transform.setRotate(lineAngle1 + 180, this.x2, this.y2);
this.arrow2.transform.baseVal.replaceItem(a2transform, 0);
}
const a1transform = this.arrow1.transform.baseVal.getItem(0);
a1transform.setRotate(lineAngle1, this.x1, this.y1);
this.arrow1.transform.baseVal.replaceItem(a1transform, 0);

const a2transform = this.arrow2.transform.baseVal.getItem(0);
a2transform.setRotate(lineAngle1 + 180, this.x2, this.y2);
this.arrow2.transform.baseVal.replaceItem(a2transform, 0);
}
}

Expand Down

0 comments on commit cefeb3d

Please sign in to comment.