mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-25 23:48:34 +02:00
Big view refresh update. No more weird algorithm and instead use small canvas option
This commit is contained in:
parent
117d6d954f
commit
3674415ce9
7 changed files with 17 additions and 87 deletions
|
@ -6174,6 +6174,7 @@ var Level = Sandbox.extend({
|
||||||
containerElement: this.goalCanvasHolder.getCanvasLocation(),
|
containerElement: this.goalCanvasHolder.getCanvasLocation(),
|
||||||
treeString: this.level.goalTreeString,
|
treeString: this.level.goalTreeString,
|
||||||
noKeyboardInput: true,
|
noKeyboardInput: true,
|
||||||
|
smallCanvas: true,
|
||||||
noClick: true
|
noClick: true
|
||||||
});
|
});
|
||||||
return this.goalCanvasHolder;
|
return this.goalCanvasHolder;
|
||||||
|
@ -15339,10 +15340,9 @@ GitVisuals.prototype.maxWidthRecursive = function(commit) {
|
||||||
return maxWidth;
|
return maxWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max, centerFrac) {
|
GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max) {
|
||||||
centerFrac = (centerFrac === undefined) ? 0.5 : centerFrac;
|
|
||||||
// I always position myself within my bounds
|
// 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;
|
commit.get('visNode').get('pos').x = myWidthPos;
|
||||||
|
|
||||||
if (commit.get('children').length === 0) {
|
if (commit.get('children').length === 0) {
|
||||||
|
@ -15361,28 +15361,6 @@ GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max, centerFr
|
||||||
}
|
}
|
||||||
}, this);
|
}, 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;
|
var prevBound = min;
|
||||||
_.each(children, function(child, index) {
|
_.each(children, function(child, index) {
|
||||||
if (!child.isMainParent(commit)) {
|
if (!child.isMainParent(commit)) {
|
||||||
|
@ -15391,12 +15369,11 @@ GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max, centerFr
|
||||||
|
|
||||||
var flex = child.get('visNode').getMaxWidthScaled();
|
var flex = child.get('visNode').getMaxWidthScaled();
|
||||||
var portion = (flex / totalFlex) * myLength;
|
var portion = (flex / totalFlex) * myLength;
|
||||||
var thisCenterFrac = getCenterFrac(index, centerFrac);
|
|
||||||
|
|
||||||
var childMin = prevBound;
|
var childMin = prevBound;
|
||||||
var childMax = childMin + portion;
|
var childMax = childMin + portion;
|
||||||
|
|
||||||
this.assignBoundsRecursive(child, childMin, childMax, thisCenterFrac);
|
this.assignBoundsRecursive(child, childMin, childMax);
|
||||||
prevBound = childMin + portion;
|
prevBound = childMin + portion;
|
||||||
}, this);
|
}, this);
|
||||||
};
|
};
|
||||||
|
@ -15491,7 +15468,7 @@ GitVisuals.prototype.animateEdges = function(speed) {
|
||||||
};
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.getMinLayers = function() {
|
GitVisuals.prototype.getMinLayers = function() {
|
||||||
return (this.options.smallCanvas) ? 4 : 7;
|
return (this.options.smallCanvas) ? 0 : 7;
|
||||||
};
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.getDepthIncrement = function(maxDepth) {
|
GitVisuals.prototype.getDepthIncrement = function(maxDepth) {
|
||||||
|
@ -25902,6 +25879,7 @@ var Level = Sandbox.extend({
|
||||||
containerElement: this.goalCanvasHolder.getCanvasLocation(),
|
containerElement: this.goalCanvasHolder.getCanvasLocation(),
|
||||||
treeString: this.level.goalTreeString,
|
treeString: this.level.goalTreeString,
|
||||||
noKeyboardInput: true,
|
noKeyboardInput: true,
|
||||||
|
smallCanvas: true,
|
||||||
noClick: true
|
noClick: true
|
||||||
});
|
});
|
||||||
return this.goalCanvasHolder;
|
return this.goalCanvasHolder;
|
||||||
|
@ -31277,10 +31255,9 @@ GitVisuals.prototype.maxWidthRecursive = function(commit) {
|
||||||
return maxWidth;
|
return maxWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max, centerFrac) {
|
GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max) {
|
||||||
centerFrac = (centerFrac === undefined) ? 0.5 : centerFrac;
|
|
||||||
// I always position myself within my bounds
|
// 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;
|
commit.get('visNode').get('pos').x = myWidthPos;
|
||||||
|
|
||||||
if (commit.get('children').length === 0) {
|
if (commit.get('children').length === 0) {
|
||||||
|
@ -31299,28 +31276,6 @@ GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max, centerFr
|
||||||
}
|
}
|
||||||
}, this);
|
}, 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;
|
var prevBound = min;
|
||||||
_.each(children, function(child, index) {
|
_.each(children, function(child, index) {
|
||||||
if (!child.isMainParent(commit)) {
|
if (!child.isMainParent(commit)) {
|
||||||
|
@ -31329,12 +31284,11 @@ GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max, centerFr
|
||||||
|
|
||||||
var flex = child.get('visNode').getMaxWidthScaled();
|
var flex = child.get('visNode').getMaxWidthScaled();
|
||||||
var portion = (flex / totalFlex) * myLength;
|
var portion = (flex / totalFlex) * myLength;
|
||||||
var thisCenterFrac = getCenterFrac(index, centerFrac);
|
|
||||||
|
|
||||||
var childMin = prevBound;
|
var childMin = prevBound;
|
||||||
var childMax = childMin + portion;
|
var childMax = childMin + portion;
|
||||||
|
|
||||||
this.assignBoundsRecursive(child, childMin, childMax, thisCenterFrac);
|
this.assignBoundsRecursive(child, childMin, childMax);
|
||||||
prevBound = childMin + portion;
|
prevBound = childMin + portion;
|
||||||
}, this);
|
}, this);
|
||||||
};
|
};
|
||||||
|
@ -31429,7 +31383,7 @@ GitVisuals.prototype.animateEdges = function(speed) {
|
||||||
};
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.getMinLayers = function() {
|
GitVisuals.prototype.getMinLayers = function() {
|
||||||
return (this.options.smallCanvas) ? 4 : 7;
|
return (this.options.smallCanvas) ? 0 : 7;
|
||||||
};
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.getDepthIncrement = function(maxDepth) {
|
GitVisuals.prototype.getDepthIncrement = function(maxDepth) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
1
build/bundle.min.js
vendored
1
build/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -426,7 +426,7 @@
|
||||||
For a much easier time perusing the source, see the individual files at:
|
For a much easier time perusing the source, see the individual files at:
|
||||||
https://github.com/pcottle/learnGitBranching
|
https://github.com/pcottle/learnGitBranching
|
||||||
-->
|
-->
|
||||||
<script src="build/bundle.min.c3a745ab.js"></script>
|
<script src="build/bundle.js"></script>
|
||||||
|
|
||||||
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
|
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
|
||||||
The downside? No raw logs to parse for analytics, so I have to include
|
The downside? No raw logs to parse for analytics, so I have to include
|
||||||
|
|
|
@ -84,6 +84,7 @@ var LevelBuilder = Level.extend({
|
||||||
containerElement: this.startCanvasHolder.getCanvasLocation(),
|
containerElement: this.startCanvasHolder.getCanvasLocation(),
|
||||||
treeString: this.level.startTree,
|
treeString: this.level.startTree,
|
||||||
noKeyboardInput: true,
|
noKeyboardInput: true,
|
||||||
|
smallCanvas: true,
|
||||||
noClick: true
|
noClick: true
|
||||||
});
|
});
|
||||||
return this.startCanvasHolder;
|
return this.startCanvasHolder;
|
||||||
|
|
|
@ -176,6 +176,7 @@ var Level = Sandbox.extend({
|
||||||
containerElement: this.goalCanvasHolder.getCanvasLocation(),
|
containerElement: this.goalCanvasHolder.getCanvasLocation(),
|
||||||
treeString: this.level.goalTreeString,
|
treeString: this.level.goalTreeString,
|
||||||
noKeyboardInput: true,
|
noKeyboardInput: true,
|
||||||
|
smallCanvas: true,
|
||||||
noClick: true
|
noClick: true
|
||||||
});
|
});
|
||||||
return this.goalCanvasHolder;
|
return this.goalCanvasHolder;
|
||||||
|
|
|
@ -510,10 +510,9 @@ GitVisuals.prototype.maxWidthRecursive = function(commit) {
|
||||||
return maxWidth;
|
return maxWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max, centerFrac) {
|
GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max) {
|
||||||
centerFrac = (centerFrac === undefined) ? 0.5 : centerFrac;
|
|
||||||
// I always position myself within my bounds
|
// 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;
|
commit.get('visNode').get('pos').x = myWidthPos;
|
||||||
|
|
||||||
if (commit.get('children').length === 0) {
|
if (commit.get('children').length === 0) {
|
||||||
|
@ -532,28 +531,6 @@ GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max, centerFr
|
||||||
}
|
}
|
||||||
}, this);
|
}, 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;
|
var prevBound = min;
|
||||||
_.each(children, function(child, index) {
|
_.each(children, function(child, index) {
|
||||||
if (!child.isMainParent(commit)) {
|
if (!child.isMainParent(commit)) {
|
||||||
|
@ -562,12 +539,11 @@ GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max, centerFr
|
||||||
|
|
||||||
var flex = child.get('visNode').getMaxWidthScaled();
|
var flex = child.get('visNode').getMaxWidthScaled();
|
||||||
var portion = (flex / totalFlex) * myLength;
|
var portion = (flex / totalFlex) * myLength;
|
||||||
var thisCenterFrac = getCenterFrac(index, centerFrac);
|
|
||||||
|
|
||||||
var childMin = prevBound;
|
var childMin = prevBound;
|
||||||
var childMax = childMin + portion;
|
var childMax = childMin + portion;
|
||||||
|
|
||||||
this.assignBoundsRecursive(child, childMin, childMax, thisCenterFrac);
|
this.assignBoundsRecursive(child, childMin, childMax);
|
||||||
prevBound = childMin + portion;
|
prevBound = childMin + portion;
|
||||||
}, this);
|
}, this);
|
||||||
};
|
};
|
||||||
|
@ -662,7 +638,7 @@ GitVisuals.prototype.animateEdges = function(speed) {
|
||||||
};
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.getMinLayers = function() {
|
GitVisuals.prototype.getMinLayers = function() {
|
||||||
return (this.options.smallCanvas) ? 4 : 7;
|
return (this.options.smallCanvas) ? 0 : 7;
|
||||||
};
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.getDepthIncrement = function(maxDepth) {
|
GitVisuals.prototype.getDepthIncrement = function(maxDepth) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue