mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-29 01:10:04 +02:00
and also bug about backbone events throwing random args
This commit is contained in:
parent
6c6c789da8
commit
eb254126cb
3 changed files with 20 additions and 17 deletions
|
@ -112,12 +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.branchCollection.add(branch, {silent: true});
|
||||
gitVisuals.addBranch(branch, true /* paper override */);
|
||||
}, this);
|
||||
gitVisuals.paperReady = true;
|
||||
|
||||
var HEAD = this.getOrMakeRecursive(tree, createdSoFar, tree.HEAD.id);
|
||||
this.HEAD = HEAD;
|
||||
|
@ -127,7 +127,6 @@ 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;
|
||||
}
|
||||
|
@ -137,13 +136,11 @@ GitEngine.prototype.reloadGraphics = function() {
|
|||
|
||||
// this just basically makes the HEAD branch. the head branch really should have been
|
||||
// a member of a collection and not this annoying edge case stuff...
|
||||
console.log('calling when git engine ready');
|
||||
gitVisuals.whenGitEngineReady(this);
|
||||
|
||||
// when the paper is ready
|
||||
gitVisuals.drawTreeFromReload();
|
||||
|
||||
console.log('refreshing harsh');
|
||||
gitVisuals.refreshTreeHarsh();
|
||||
};
|
||||
|
||||
|
|
|
@ -123,14 +123,11 @@ 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')
|
||||
|
|
|
@ -18,7 +18,7 @@ function GitVisuals(options) {
|
|||
|
||||
this.commitCollection.on('change', this.collectionChanged, this);
|
||||
|
||||
this.branchCollection.on('add', this.addBranch, this);
|
||||
this.branchCollection.on('add', this.addBranchFromEvent, this);
|
||||
this.branchCollection.on('remove', this.removeBranch, this);
|
||||
|
||||
events.on('canvasResize', _.bind(
|
||||
|
@ -362,14 +362,26 @@ GitVisuals.prototype.animateNodePositions = function(speed) {
|
|||
}, this);
|
||||
};
|
||||
|
||||
GitVisuals.prototype.addBranch = function(branch) {
|
||||
GitVisuals.prototype.turnOnPaper = function() {
|
||||
this.paperReady = false;
|
||||
};
|
||||
|
||||
// does making an accessor method make it any less hacky? that is the true question
|
||||
GitVisuals.prototype.turnOffPaper = function() {
|
||||
this.paperReady = true;
|
||||
};
|
||||
|
||||
GitVisuals.prototype.addBranchFromEvent = function(branch, collection, index) {
|
||||
this.addBranch(branch);
|
||||
};
|
||||
|
||||
GitVisuals.prototype.addBranch = function(branch, paperOverride) {
|
||||
var visBranch = new VisBranch({
|
||||
branch: branch
|
||||
});
|
||||
|
||||
this.visBranchCollection.add(visBranch);
|
||||
if (this.paperReady) {
|
||||
console.log('PAPEPR IS READY');
|
||||
if (!paperOverride && this.paperReady) {
|
||||
visBranch.genGraphics(paper);
|
||||
}
|
||||
};
|
||||
|
@ -511,17 +523,14 @@ GitVisuals.prototype.drawTreeFirstTime = function() {
|
|||
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