Big view refresh update. No more weird algorithm and instead use small canvas option

This commit is contained in:
Peter Cottle 2013-05-25 13:29:00 -07:00
parent 117d6d954f
commit 3674415ce9
7 changed files with 17 additions and 87 deletions

View file

@ -510,10 +510,9 @@ GitVisuals.prototype.maxWidthRecursive = function(commit) {
return maxWidth;
};
GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max, centerFrac) {
centerFrac = (centerFrac === undefined) ? 0.5 : centerFrac;
GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max) {
// I always position myself within my bounds
var myWidthPos = min + (max - min) * centerFrac;
var myWidthPos = (max + min) / 2.0;
commit.get('visNode').get('pos').x = myWidthPos;
if (commit.get('children').length === 0) {
@ -532,28 +531,6 @@ GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max, centerFr
}
}, this);
// TODO: refactor into another method
var getCenterFrac = function(index, centerFrac) {
if (myLength < 0.99) {
if (children.length < 2) {
return centerFrac;
} else {
return 0.5;
}
}
if (children.length < 2) {
return 0.5;
}
// we introduce a VERY specific rule here, to push out
// the first "divergence" of the graph
if (index === 0) {
return 1/3;
} else if (index === children.length - 1) {
return 2/3;
}
return centerFrac;
};
var prevBound = min;
_.each(children, function(child, index) {
if (!child.isMainParent(commit)) {
@ -562,12 +539,11 @@ GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max, centerFr
var flex = child.get('visNode').getMaxWidthScaled();
var portion = (flex / totalFlex) * myLength;
var thisCenterFrac = getCenterFrac(index, centerFrac);
var childMin = prevBound;
var childMax = childMin + portion;
this.assignBoundsRecursive(child, childMin, childMax, thisCenterFrac);
this.assignBoundsRecursive(child, childMin, childMax);
prevBound = childMin + portion;
}, this);
};
@ -662,7 +638,7 @@ GitVisuals.prototype.animateEdges = function(speed) {
};
GitVisuals.prototype.getMinLayers = function() {
return (this.options.smallCanvas) ? 4 : 7;
return (this.options.smallCanvas) ? 0 : 7;
};
GitVisuals.prototype.getDepthIncrement = function(maxDepth) {