Skip to content

Commit

Permalink
Baseline is now customizable in sandboxes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wei Wang committed Mar 26, 2013
1 parent 2367ab0 commit 0033f32
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
8 changes: 6 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ <h4>Interacting with Remote Server</h4>

explainGit.open({
name: 'Commit',
height: 250,
height: 200,
baseLine: 0.4,
commitData: [
{id: 'e137e9b', tags: ['origin/master', 'master']}
],
Expand All @@ -210,6 +211,7 @@ <h4>Interacting with Remote Server</h4>

explainGit.open({
name: 'Branch',
baseLine: 0.6,
commitData: [
{id: 'e137e9b', tags: ['origin/master', 'master']}
]
Expand Down Expand Up @@ -281,7 +283,8 @@ <h4>Interacting with Remote Server</h4>

explainGit.open({
name: 'Reset',
height: 250,
height: 200,
baseLine: 0.4,
commitData: [
{id: 'e137e9b', tags: ['origin/master']},
{id: '0e70093', parent: 'e137e9b'},
Expand All @@ -306,6 +309,7 @@ <h4>Interacting with Remote Server</h4>
explainGit.open({
name: 'Branch-d',
height: 500,
baseLine: 0.6,
commitData: [
{id: 'e137e9b', tags: ['origin/master']},
{id: 'bb92e0e', parent: 'e137e9b'},
Expand Down
18 changes: 10 additions & 8 deletions js/historyview.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define(['d3'], function () {

preventOverlap = function preventOverlap(commit, view) {
var commitData = view.commitData,
centerBranchLine = view.height / 2,
baseLine = view.baseLine,
shift = view.commitRadius * 4.5,
overlapped = null;

Expand All @@ -30,7 +30,7 @@ define(['d3'], function () {
var oParent = view.getCommit(overlapped.parent),
parent = view.getCommit(commit.parent);

if (overlapped.cy < centerBranchLine) {
if (overlapped.cy < baseLine) {
overlapped = oParent.cy < parent.cy ? overlapped : commit;
overlapped.cy -= shift;
} else {
Expand Down Expand Up @@ -78,7 +78,7 @@ define(['d3'], function () {
cy = function (commit, view) {
var parent = view.getCommit(commit.parent),
parentCY = parent.cy,
centerBranchLine = view.height / 2,
baseLine = view.baseLine,
shift = view.commitRadius * 4.5,
branches = [], // count the existing branches
branchIndex = 0;
Expand All @@ -93,7 +93,7 @@ define(['d3'], function () {

branchIndex = branches.indexOf(commit.id);

if (parentCY === centerBranchLine) {
if (parentCY === baseLine) {
var direction = 1;
for (var bi = 0; bi < branchIndex; bi++) {
direction *= -1;
Expand All @@ -104,9 +104,9 @@ define(['d3'], function () {
return parentCY + (shift * direction);
}

if (parentCY < centerBranchLine) {
if (parentCY < baseLine) {
return parentCY - (shift * branchIndex);
} else if (parentCY > centerBranchLine) {
} else if (parentCY > baseLine) {
return parentCY + (shift * branchIndex);
}
};
Expand Down Expand Up @@ -205,7 +205,7 @@ define(['d3'], function () {
tagIndex = tags.length;
}

if (commitCY < (view.height / 2)) {
if (commitCY < (view.baseLine)) {
return commitCY - 45 - (tagIndex * 25);
} else {
return commitCY + 40 + (tagIndex * 25);
Expand Down Expand Up @@ -234,14 +234,16 @@ define(['d3'], function () {

this.width = config.width || 886;
this.height = config.height || 400;
this.baseLine = this.height * (config.baseLine || 0.7);

this.commitRadius = config.commitRadius || 20;
this.pointerMargin = this.commitRadius * 1.3;

this.initialCommit = {
id: 'initial',
parent: null,
cx: -(this.commitRadius * 2),
cy: this.height / 2
cy: this.baseLine
};
}

Expand Down

0 comments on commit 0033f32

Please sign in to comment.