mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 00:18:56 +02:00
FIXED RELOADINGGGGGGGGGGGGGGGG
This commit is contained in:
parent
5272cfea47
commit
6c6c789da8
3 changed files with 35 additions and 7 deletions
14
src/git.js
14
src/git.js
|
@ -92,6 +92,7 @@ GitEngine.prototype.printAndCopyTree = function() {
|
|||
|
||||
GitEngine.prototype.loadTree = function(tree) {
|
||||
// first clear everything
|
||||
// debugger
|
||||
this.removeAll();
|
||||
|
||||
this.instantiateFromTree(tree);
|
||||
|
@ -111,10 +112,12 @@ GitEngine.prototype.instantiateFromTree = function(tree) {
|
|||
this.commitCollection.add(commit);
|
||||
}, this);
|
||||
|
||||
gitVisuals.paperReady = false;
|
||||
_.each(tree.branches, function(branchJSON) {
|
||||
var branch = this.getOrMakeRecursive(tree, createdSoFar, branchJSON.id);
|
||||
this.branchCollection.add(branch);
|
||||
}, this);
|
||||
gitVisuals.paperReady = true;
|
||||
|
||||
var HEAD = this.getOrMakeRecursive(tree, createdSoFar, tree.HEAD.id);
|
||||
this.HEAD = HEAD;
|
||||
|
@ -122,11 +125,14 @@ GitEngine.prototype.instantiateFromTree = function(tree) {
|
|||
|
||||
GitEngine.prototype.reloadGraphics = function() {
|
||||
var rootCommit = null;
|
||||
|
||||
this.commitCollection.each(function(commit) {
|
||||
console.log('finding commit from collection', commit.get('id'));
|
||||
if (commit.get('id') == 'C0') {
|
||||
rootCommit = commit;
|
||||
}
|
||||
});
|
||||
|
||||
gitVisuals.rootCommit = rootCommit;
|
||||
|
||||
// this just basically makes the HEAD branch. the head branch really should have been
|
||||
|
@ -135,9 +141,9 @@ GitEngine.prototype.reloadGraphics = function() {
|
|||
gitVisuals.whenGitEngineReady(this);
|
||||
|
||||
// when the paper is ready
|
||||
gitVisuals.drawTreeFirstTime();
|
||||
gitVisuals.drawTreeFromReload();
|
||||
|
||||
console.log('refreshing hars');
|
||||
console.log('refreshing harsh');
|
||||
gitVisuals.refreshTreeHarsh();
|
||||
};
|
||||
|
||||
|
@ -209,10 +215,10 @@ GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
|
|||
};
|
||||
|
||||
GitEngine.prototype.removeAll = function() {
|
||||
gitVisuals.resetAll();
|
||||
|
||||
this.branchCollection.reset();
|
||||
this.commitCollection.reset();
|
||||
|
||||
gitVisuals.resetAll();
|
||||
};
|
||||
|
||||
GitEngine.prototype.getDetachedHead = function() {
|
||||
|
|
11
src/tree.js
11
src/tree.js
|
@ -123,10 +123,14 @@ var VisBranch = VisBase.extend({
|
|||
},
|
||||
|
||||
getRectPosition: function() {
|
||||
console.log('before text pos');
|
||||
var pos = this.getTextPosition();
|
||||
console.log('wut');
|
||||
var f = this.get('flip');
|
||||
// first get text width and height
|
||||
console.log('before text size');
|
||||
var textSize = this.getTextSize();
|
||||
console.log('text size');
|
||||
return {
|
||||
x: pos.x - 0.5 * textSize.w - this.get('hPad'),
|
||||
y: pos.y - 0.5 * textSize.h - this.get('vPad')
|
||||
|
@ -274,10 +278,13 @@ var VisBranch = VisBase.extend({
|
|||
},
|
||||
|
||||
genGraphics: function(paper) {
|
||||
var textPos = this.getTextPosition();
|
||||
|
||||
var textPos = this.getTextPosition();
|
||||
var name = this.getName();
|
||||
var text = paper.text(textPos.x, textPos.y, String(name));
|
||||
var text;
|
||||
|
||||
// when from a reload, we dont need to generate the text
|
||||
text = paper.text(textPos.x, textPos.y, String(name));
|
||||
text.attr({
|
||||
'font-size': 14,
|
||||
'font-family': 'Monaco, Courier, font-monospace',
|
||||
|
|
|
@ -369,6 +369,7 @@ GitVisuals.prototype.addBranch = function(branch) {
|
|||
|
||||
this.visBranchCollection.add(visBranch);
|
||||
if (this.paperReady) {
|
||||
console.log('PAPEPR IS READY');
|
||||
visBranch.genGraphics(paper);
|
||||
}
|
||||
};
|
||||
|
@ -494,19 +495,33 @@ GitVisuals.prototype.visBranchesFront = function() {
|
|||
});
|
||||
};
|
||||
|
||||
GitVisuals.prototype.drawTreeFromReload = function() {
|
||||
this.paperReady = true;
|
||||
this.calcTreeCoords();
|
||||
|
||||
this.visBranchCollection.each(function(visBranch) {
|
||||
visBranch.genGraphics(paper, {
|
||||
fromReload: true
|
||||
});
|
||||
}, this);
|
||||
};
|
||||
|
||||
GitVisuals.prototype.drawTreeFirstTime = function() {
|
||||
this.paperReady = true;
|
||||
this.calcTreeCoords();
|
||||
|
||||
_.each(this.visNodeMap, function(visNode) {
|
||||
console.log('visnode map is doing', visNode);
|
||||
visNode.genGraphics(paper);
|
||||
}, this);
|
||||
|
||||
this.visEdgeCollection.each(function(edge) {
|
||||
console.log('vis edge collection', edge);
|
||||
edge.genGraphics(paper);
|
||||
}, this);
|
||||
|
||||
this.visBranchCollection.each(function(visBranch) {
|
||||
console.log('vis rabnch', visBranch);
|
||||
visBranch.genGraphics(paper);
|
||||
}, this);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue