mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 08:28:50 +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) {
|
GitEngine.prototype.loadTree = function(tree) {
|
||||||
// first clear everything
|
// first clear everything
|
||||||
|
// debugger
|
||||||
this.removeAll();
|
this.removeAll();
|
||||||
|
|
||||||
this.instantiateFromTree(tree);
|
this.instantiateFromTree(tree);
|
||||||
|
@ -111,10 +112,12 @@ GitEngine.prototype.instantiateFromTree = function(tree) {
|
||||||
this.commitCollection.add(commit);
|
this.commitCollection.add(commit);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
gitVisuals.paperReady = false;
|
||||||
_.each(tree.branches, function(branchJSON) {
|
_.each(tree.branches, function(branchJSON) {
|
||||||
var branch = this.getOrMakeRecursive(tree, createdSoFar, branchJSON.id);
|
var branch = this.getOrMakeRecursive(tree, createdSoFar, branchJSON.id);
|
||||||
this.branchCollection.add(branch);
|
this.branchCollection.add(branch);
|
||||||
}, this);
|
}, this);
|
||||||
|
gitVisuals.paperReady = true;
|
||||||
|
|
||||||
var HEAD = this.getOrMakeRecursive(tree, createdSoFar, tree.HEAD.id);
|
var HEAD = this.getOrMakeRecursive(tree, createdSoFar, tree.HEAD.id);
|
||||||
this.HEAD = HEAD;
|
this.HEAD = HEAD;
|
||||||
|
@ -122,11 +125,14 @@ GitEngine.prototype.instantiateFromTree = function(tree) {
|
||||||
|
|
||||||
GitEngine.prototype.reloadGraphics = function() {
|
GitEngine.prototype.reloadGraphics = function() {
|
||||||
var rootCommit = null;
|
var rootCommit = null;
|
||||||
|
|
||||||
this.commitCollection.each(function(commit) {
|
this.commitCollection.each(function(commit) {
|
||||||
|
console.log('finding commit from collection', commit.get('id'));
|
||||||
if (commit.get('id') == 'C0') {
|
if (commit.get('id') == 'C0') {
|
||||||
rootCommit = commit;
|
rootCommit = commit;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
gitVisuals.rootCommit = rootCommit;
|
gitVisuals.rootCommit = rootCommit;
|
||||||
|
|
||||||
// this just basically makes the HEAD branch. the head branch really should have been
|
// 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);
|
gitVisuals.whenGitEngineReady(this);
|
||||||
|
|
||||||
// when the paper is ready
|
// when the paper is ready
|
||||||
gitVisuals.drawTreeFirstTime();
|
gitVisuals.drawTreeFromReload();
|
||||||
|
|
||||||
console.log('refreshing hars');
|
console.log('refreshing harsh');
|
||||||
gitVisuals.refreshTreeHarsh();
|
gitVisuals.refreshTreeHarsh();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -209,10 +215,10 @@ GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.removeAll = function() {
|
GitEngine.prototype.removeAll = function() {
|
||||||
gitVisuals.resetAll();
|
|
||||||
|
|
||||||
this.branchCollection.reset();
|
this.branchCollection.reset();
|
||||||
this.commitCollection.reset();
|
this.commitCollection.reset();
|
||||||
|
|
||||||
|
gitVisuals.resetAll();
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.getDetachedHead = function() {
|
GitEngine.prototype.getDetachedHead = function() {
|
||||||
|
|
11
src/tree.js
11
src/tree.js
|
@ -123,10 +123,14 @@ var VisBranch = VisBase.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getRectPosition: function() {
|
getRectPosition: function() {
|
||||||
|
console.log('before text pos');
|
||||||
var pos = this.getTextPosition();
|
var pos = this.getTextPosition();
|
||||||
|
console.log('wut');
|
||||||
var f = this.get('flip');
|
var f = this.get('flip');
|
||||||
// first get text width and height
|
// first get text width and height
|
||||||
|
console.log('before text size');
|
||||||
var textSize = this.getTextSize();
|
var textSize = this.getTextSize();
|
||||||
|
console.log('text size');
|
||||||
return {
|
return {
|
||||||
x: pos.x - 0.5 * textSize.w - this.get('hPad'),
|
x: pos.x - 0.5 * textSize.w - this.get('hPad'),
|
||||||
y: pos.y - 0.5 * textSize.h - this.get('vPad')
|
y: pos.y - 0.5 * textSize.h - this.get('vPad')
|
||||||
|
@ -274,10 +278,13 @@ var VisBranch = VisBase.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
genGraphics: function(paper) {
|
genGraphics: function(paper) {
|
||||||
var textPos = this.getTextPosition();
|
|
||||||
|
|
||||||
|
var textPos = this.getTextPosition();
|
||||||
var name = this.getName();
|
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({
|
text.attr({
|
||||||
'font-size': 14,
|
'font-size': 14,
|
||||||
'font-family': 'Monaco, Courier, font-monospace',
|
'font-family': 'Monaco, Courier, font-monospace',
|
||||||
|
|
|
@ -369,6 +369,7 @@ GitVisuals.prototype.addBranch = function(branch) {
|
||||||
|
|
||||||
this.visBranchCollection.add(visBranch);
|
this.visBranchCollection.add(visBranch);
|
||||||
if (this.paperReady) {
|
if (this.paperReady) {
|
||||||
|
console.log('PAPEPR IS READY');
|
||||||
visBranch.genGraphics(paper);
|
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() {
|
GitVisuals.prototype.drawTreeFirstTime = function() {
|
||||||
this.paperReady = true;
|
this.paperReady = true;
|
||||||
this.calcTreeCoords();
|
this.calcTreeCoords();
|
||||||
|
|
||||||
_.each(this.visNodeMap, function(visNode) {
|
_.each(this.visNodeMap, function(visNode) {
|
||||||
|
console.log('visnode map is doing', visNode);
|
||||||
visNode.genGraphics(paper);
|
visNode.genGraphics(paper);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
this.visEdgeCollection.each(function(edge) {
|
this.visEdgeCollection.each(function(edge) {
|
||||||
|
console.log('vis edge collection', edge);
|
||||||
edge.genGraphics(paper);
|
edge.genGraphics(paper);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
this.visBranchCollection.each(function(visBranch) {
|
this.visBranchCollection.each(function(visBranch) {
|
||||||
|
console.log('vis rabnch', visBranch);
|
||||||
visBranch.genGraphics(paper);
|
visBranch.genGraphics(paper);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue