mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-14 16:44:26 +02:00
AWESOME refresh of visbranch visuals way better layout
This commit is contained in:
parent
6091fd5a2e
commit
30c6713007
1 changed files with 38 additions and 2 deletions
|
@ -65,6 +65,7 @@ var VisBranch = VisBase.extend({
|
||||||
// switch to a head ref
|
// switch to a head ref
|
||||||
this.set('isHead', true);
|
this.set('isHead', true);
|
||||||
this.set('flip', -1);
|
this.set('flip', -1);
|
||||||
|
this.refreshOffset();
|
||||||
|
|
||||||
this.set('fill', GRAPHICS.headRectFill);
|
this.set('fill', GRAPHICS.headRectFill);
|
||||||
} else if (id !== 'master') {
|
} else if (id !== 'master') {
|
||||||
|
@ -77,11 +78,12 @@ var VisBranch = VisBase.extend({
|
||||||
var commit = this.gitEngine.getCommitFromRef(this.get('branch'));
|
var commit = this.gitEngine.getCommitFromRef(this.get('branch'));
|
||||||
var visNode = commit.get('visNode');
|
var visNode = commit.get('visNode');
|
||||||
|
|
||||||
this.set('flip', this.getFlipBool(commit, visNode));
|
this.set('flip', this.getFlipValue(commit, visNode));
|
||||||
|
this.refreshOffset();
|
||||||
return visNode.getScreenCoords();
|
return visNode.getScreenCoords();
|
||||||
},
|
},
|
||||||
|
|
||||||
getFlipBool: function(commit, visNode) {
|
getFlipValue: function(commit, visNode) {
|
||||||
var threshold = this.get('gitVisuals').getFlipPos();
|
var threshold = this.get('gitVisuals').getFlipPos();
|
||||||
var overThreshold = (visNode.get('pos').x > threshold);
|
var overThreshold = (visNode.get('pos').x > threshold);
|
||||||
|
|
||||||
|
@ -100,6 +102,39 @@ var VisBranch = VisBase.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
shouldOffsetY: function() {
|
||||||
|
return this.gitEngine.getBranches().length > 1;
|
||||||
|
},
|
||||||
|
|
||||||
|
refreshOffset: function() {
|
||||||
|
var baseOffsetX = GRAPHICS.nodeRadius * 4.75;
|
||||||
|
if (!this.shouldOffsetY()) {
|
||||||
|
this.set('offsetY', 0);
|
||||||
|
this.set('offsetX', baseOffsetX);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var offsetY = 33;
|
||||||
|
var deltaX = 10;
|
||||||
|
if (this.get('flip') === 1) {
|
||||||
|
this.set('offsetY', -offsetY);
|
||||||
|
this.set('offsetX', baseOffsetX - deltaX);
|
||||||
|
} else {
|
||||||
|
this.set('offsetY', offsetY);
|
||||||
|
this.set('offsetX', baseOffsetX - deltaX);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getArrowTransform: function() {
|
||||||
|
if (!this.shouldOffsetY()) {
|
||||||
|
return '';
|
||||||
|
} else if (this.get('flip') === 1) {
|
||||||
|
return 't-2,-20R-35';
|
||||||
|
} else {
|
||||||
|
return 't-2,20R-35';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
getBranchStackIndex: function() {
|
getBranchStackIndex: function() {
|
||||||
if (this.get('isHead')) {
|
if (this.get('isHead')) {
|
||||||
// head is never stacked with other branches
|
// head is never stacked with other branches
|
||||||
|
@ -463,6 +498,7 @@ var VisBranch = VisBase.extend({
|
||||||
opacity: nonTextOpacity,
|
opacity: nonTextOpacity,
|
||||||
fill: this.getFill(),
|
fill: this.getFill(),
|
||||||
stroke: this.get('stroke'),
|
stroke: this.get('stroke'),
|
||||||
|
transform: this.getArrowTransform(),
|
||||||
'stroke-width': this.get('stroke-width')
|
'stroke-width': this.get('stroke-width')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue