diff --git a/src/tree.js b/src/tree.js index c2e10e30..014756ff 100644 --- a/src/tree.js +++ b/src/tree.js @@ -28,12 +28,9 @@ var VisBranch = Backbone.Model.extend({ genGraphics: function(paper) { var pos = this.getPosition(); - if (!paper) { - console.log('no paper'); - return; - } var name = this.get('branch').get('id'); var text = paper.text(pos.x, pos.y, String(name)); + text.attr({ 'font-size': 16 }); @@ -46,7 +43,8 @@ var VisBranch = Backbone.Model.extend({ x: pos.x, y: pos.y }, - speed || this.get('animationSpeed'), + // speed can be 0 when we want a harsh animation + speed !== undefined ? speed : this.get('animationSpeed'), easing || this.get('animationEasing') ); } @@ -100,7 +98,7 @@ var VisNode = Backbone.Model.extend({ cx: pos.x, cy: pos.y }, - speed || this.get('animationSpeed'), + speed !== undefined ? speed : this.get('animationSpeed'), easing || this.get('animationEasing') ); }, @@ -210,7 +208,7 @@ var VisEdge = Backbone.Model.extend({ this.get('path').stop().animate({ path: newPath }, - speed || this.get('animationSpeed'), + speed !== undefined ? speed : this.get('animationSpeed'), easing || this.get('animationEasing') ); }, diff --git a/src/visuals.js b/src/visuals.js index 150b6477..926bf66b 100644 --- a/src/visuals.js +++ b/src/visuals.js @@ -71,19 +71,21 @@ GitVisuals.prototype.toScreenCoords = function(pos) { **************************************/ GitVisuals.prototype.refreshTree = function() { - if (!this.paperReady) { console.warn('called refresh tree when not ready yet'); return; } - this.calculateTreeCoords(); - this.animateNodePositions(); - this.animateEdges(); - this.animateRefs(); + + this.animateAll(); }; GitVisuals.prototype.refreshTreeHarsh = function() { this.calculateTreeCoords(); - this.animateEdges(); - this.animateNodePositions(); + this.animateAll(0); +}; + +GitVisuals.prototype.animateAll = function(speed) { + this.animateEdges(speed); + this.animateNodePositions(speed); + this.animateRefs(speed); }; GitVisuals.prototype.calculateTreeCoords = function() { @@ -180,9 +182,9 @@ GitVisuals.prototype.calcDepth = function() { **************************************/ -GitVisuals.prototype.animateNodePositions = function() { +GitVisuals.prototype.animateNodePositions = function(speed) { _.each(this.visNodeMap, function(visNode) { - visNode.animateUpdatedPosition(); + visNode.animateUpdatedPosition(speed); }, this); }; @@ -196,15 +198,15 @@ GitVisuals.prototype.addBranch = function(branch) { } }; -GitVisuals.prototype.animateRefs = function() { +GitVisuals.prototype.animateRefs = function(speed) { this.visBranchCollection.each(function(visBranch) { - visBranch.animateUpdatedPos(paper); + visBranch.animateUpdatedPos(speed); }, this); }; -GitVisuals.prototype.animateEdges = function() { +GitVisuals.prototype.animateEdges = function(speed) { this.edgeCollection.each(function(edge) { - edge.animateUpdatedPath(); + edge.animateUpdatedPath(speed); }, this); }; @@ -232,7 +234,12 @@ GitVisuals.prototype.calcDepthRecursive = function(commit, depth) { GitVisuals.prototype.canvasResize = function(width, height) { this.paperWidth = width; this.paperHeight = height; - // TODO figure out whether we are animating or not and possibly delay this + + // there will be one resize before paper is ready -- if so, dont call it + if (!this.paperReady) { + return; + } + this.refreshTree(); }; @@ -294,7 +301,7 @@ GitVisuals.prototype.drawTreeFirstTime = function() { visBranch.genGraphics(paper); }, this); - this.refreshTree(); + this.refreshTreeHarsh(); };