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

Commit 9f1e225

Browse files
authored
Merge pull request #154 from yodalee/issue140-vertical-arrow-with-multiple-branch-commit
Close #140. Vertical arrow with multiple branch commit.
2 parents 69e9a36 + 3448edb commit 9f1e225

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/gitgraph.js

+17-15
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@
505505
this.height = 0;
506506
this.width = 0;
507507
this.commits = [];
508-
this.path = []; // Path to draw, this is an array of points {x, y, type("start"|"join"|"end")}
508+
this.path = []; // Path to draw, this is an array of points {x, y, type("start"|"joint"|"end")}
509509

510510
// Column number calculation for auto-color & auto-offset
511511
if (typeof options.column === "number") {
@@ -757,23 +757,25 @@
757757
var point = {
758758
x: commit.x,
759759
y: commit.y,
760-
type: "join"
760+
type: "joint"
761761
};
762762

763763
if (!isFirstBranch && isPathBeginning) {
764764
this.pushPath(this.startPoint);
765-
766-
// Trace path from parent branch if it has commits already
767-
if (this.parentBranch.commits.length > 0) {
765+
// Add a path joint to startpoint + template spacing
766+
// So that line will not go through commit of other branches
767+
if ((this.parent.orientation === "vertical-reverse") || (this.parent.orientation === "vertical")) {
768768
this.pushPath({
769-
x: this.startPoint.x - this.parentBranch.offsetX + this.offsetX - this.template.commit.spacingX,
770-
y: this.startPoint.y - this.parentBranch.offsetY + this.offsetY - this.template.commit.spacingY,
771-
type: "join"
769+
x: commit.x,
770+
y: this.startPoint.y - this.template.commit.spacingY,
771+
type: "joint"
772+
});
773+
} else {
774+
this.pushPath({
775+
x: this.startPoint.x - this.template.commit.spacingX,
776+
y: commit.y,
777+
type: "joint"
772778
});
773-
774-
var parent = _clone(this.startPoint);
775-
parent.type = "join";
776-
this.parentBranch.pushPath(parent);
777779
}
778780
} else if (isPathBeginning) {
779781
point.type = "start";
@@ -932,7 +934,7 @@
932934
var endOfBranch = {
933935
x: this.offsetX + this.template.commit.spacingX * (targetCommit.showLabel ? 3 : 2) - this.parent.commitOffsetX,
934936
y: this.offsetY + this.template.commit.spacingY * (targetCommit.showLabel ? 3 : 2) - this.parent.commitOffsetY,
935-
type: "join"
937+
type: "joint"
936938
};
937939
this.pushPath(_clone(endOfBranch));
938940

@@ -994,13 +996,13 @@
994996
} else if (lastPoint.x === point.x && lastPoint.y === point.y) {
995997
if (lastPoint.type !== "start" && point.type === "end") {
996998
lastPoint.type = "end";
997-
} else if (point.type === "join") {
999+
} else if (point.type === "joint") {
9981000

9991001
} else {
10001002
this.path.push(point);
10011003
}
10021004
} else {
1003-
if (point.type === "join") {
1005+
if (point.type === "joint") {
10041006
if ((point.x - lastPoint.x) * this.template.commit.spacingX < 0) {
10051007
this.path.push(point);
10061008
} else if ((point.y - lastPoint.y) * this.template.commit.spacingY < 0) {

0 commit comments

Comments
 (0)