diff --git a/src/git.js b/src/git.js index 3bec7224..49cf1f24 100644 --- a/src/git.js +++ b/src/git.js @@ -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(); }; diff --git a/src/tree.js b/src/tree.js index 6a49db23..561bc254 100644 --- a/src/tree.js +++ b/src/tree.js @@ -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') diff --git a/src/visuals.js b/src/visuals.js index a9291bee..20d3c91f 100644 --- a/src/visuals.js +++ b/src/visuals.js @@ -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);