mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 16:08:34 +02:00
nicer preview working on assertions
This commit is contained in:
parent
092a92b0b4
commit
5754238864
7 changed files with 69 additions and 15 deletions
|
@ -516,21 +516,37 @@ GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max) {
|
|||
}
|
||||
}, this);
|
||||
|
||||
var prevBound = min;
|
||||
var checkPortion = function(portion, index) {
|
||||
if (myLength < 0.99 || children.length < 2) {
|
||||
return portion;
|
||||
}
|
||||
// we introduce a VERY specific rule here, to push out
|
||||
// the first "divergence" of the graph
|
||||
if (index === 0) {
|
||||
portion *= 1/3;
|
||||
} else if (index === children.length - 1) {
|
||||
portion *= 5/3;
|
||||
}
|
||||
return portion;
|
||||
};
|
||||
|
||||
var prevBound = min;
|
||||
// now go through and do everything
|
||||
// TODO: order so the max width children are in the middle!!
|
||||
_.each(children, function(child) {
|
||||
_.each(children, function(child, index) {
|
||||
if (!child.isMainParent(commit)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var flex = child.get('visNode').getMaxWidthScaled();
|
||||
var portion = (flex / totalFlex) * myLength;
|
||||
var adjustedPortion = checkPortion(portion, index);
|
||||
|
||||
var childMin = prevBound;
|
||||
var childMax = childMin + portion;
|
||||
var childMax = childMin + adjustedPortion;
|
||||
|
||||
this.assignBoundsRecursive(child, childMin, childMax);
|
||||
prevBound = childMax;
|
||||
prevBound = childMin + portion;
|
||||
}, this);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue