diff --git a/src/animationFactory.js b/src/animationFactory.js index fde3d31d..95c3aab4 100644 --- a/src/animationFactory.js +++ b/src/animationFactory.js @@ -42,25 +42,7 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co }; AnimationFactory.prototype.genCommitBirthAnimationInSequence = function(animationQueue, index, commits) { - if (!animationQueue) { throw new Error("rawrr"); } - var time = GRAPHICS.defaultAnimationTime * 1.0; - var bounceTime = time * 2.0; - - var toHide = commits.slice(index + 1); - var visNode = commits[index].get('visNode'); - - var animation = function() { - visNode.parentInFront(); - - visNode.animateUpdatedPosition(bounceTime, 'bounce'); - visNode.animateOutgoingEdges(time); - }; - - animationQueue.add(new Animation({ - closure: animation, - duration: Math.max(time, bounceTime) - })); }; AnimationFactory.prototype.refreshTree = function(animationQueue) { diff --git a/src/git.js b/src/git.js index 0c5b9c5b..0ffa8918 100644 --- a/src/git.js +++ b/src/git.js @@ -487,32 +487,54 @@ GitEngine.prototype.rebaseStarter = function() { // was a fastforward or already up to date return; } + this.rebaseAnimation(response); }; GitEngine.prototype.rebaseAnimation = function(response) { - var newCommits = response; - var start = function() { - gitVisuals.calcTreeCoords(); - gitVisuals.animateEdges(); - gitVisuals.animateNodePositions(); - - _.each(newCommits, function(c) { - c.get('visNode').setBirth(); - }); + // maybe search stuff?? }; this.animationQueue.add(new Animation({ closure: start })); + + // first set all birth positions... + _.each(response, function(step) { + step.newCommit.get('visNode').setBirth(); + }, this); - gitVisuals.calcTreeCoords(); - // make a bunch of birthing animations - for (var i = 0; i < newCommits.length; i++) { - newCommits[i].get('visNode').setBirth(); - animationFactory.genCommitBirthAnimationInSequence(this.animationQueue, i, newCommits); - } + var fixedOpacity = 0.8; + // then fix all opacities... ugh + _.each(response, function(step) { + _.each(step.snapshot, function(obj) { + _.each(obj, function(attr) { + if (attr.opacity !== undefined) { + attr.opacity = fixedOpacity; + } + }); + }); + }); + + var time = GRAPHICS.defaultAnimationTime; + var bounceTime = time * 2.0; + + _.each(response, function(step) { + this.animationQueue.add(new Animation({ + closure: function() { + var id = step.newCommit.get('id'); + var vNode = step.newCommit.get('visNode'); + + vNode.setBirth(); + vNode.setOutgoingEdgesBirthPosition(); + + vNode.animateOutgoingEdgesFromSnapshot(step.snapshot, bounceTime, 'bounce'); + vNode.animateFromAttr(step.snapshot[id], bounceTime, 'bounce'); + }, + duration: Math.max(bounceTime, time) + })); + }, this); animationFactory.refreshTree(this.animationQueue); }; @@ -572,21 +594,26 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) { // now pop all of these commits onto targetLocation var base = this.getCommitFromRef(targetSource); - var newCommits = []; - + var animationInfo = []; for (var i = 0; i < toRebase.length; i++) { var old = toRebase[i]; var newId = this.rebaseAltId(old.get('id')); var newCommit = this.makeCommit([base], newId); - newCommits.push(newCommit); + base = newCommit; + + animationInfo.push({ + oldCommit: old, + newCommit: newCommit, + snapshot: gitVisuals.genSnapshot() + }); } // now we just need to update where we are this.setLocationTarget(currentLocation, base); // for animation - return newCommits; + return animationInfo; }; GitEngine.prototype.mergeStarter = function() { diff --git a/src/tree.js b/src/tree.js index 57db6cb8..482ff68f 100644 --- a/src/tree.js +++ b/src/tree.js @@ -320,10 +320,10 @@ var VisBranch = Backbone.Model.extend({ animateUpdatedPos: function(speed, easing) { var attr = this.getAttributes(); - this.animateFromAttributes(speed, easing, attr); + this.animateFromAttr(attr, speed, easing); }, - animateFromAttributes: function(speed, easing, attr) { + animateFromAttr: function(attr, speed, easing) { var s = speed !== undefined ? speed : this.get('animationSpeed'); var e = easing || this.get('animationEasing'); @@ -422,10 +422,10 @@ var VisNode = Backbone.Model.extend({ animateUpdatedPosition: function(speed, easing) { var attr = this.getAttributes(); - this.animateFromAttr(speed, easing, attr); + this.animateFromAttr(attr, speed, easing); }, - animateFromAttr: function(speed, easing, attr) { + animateFromAttr: function(attr, speed, easing) { this.get('circle').stop().animate( attr.circle, speed !== undefined ? speed : this.get('animationSpeed'), @@ -469,6 +469,13 @@ var VisNode = Backbone.Model.extend({ }, this); }, + animateOutgoingEdgesFromSnapshot: function(snapshot, speed, easing) { + _.each(this.get('outgoingEdges'), function(edge) { + var attr = snapshot[edge.getID()]; + edge.animateFromAttr(attr, speed, easing); + }, this); + }, + setOutgoingEdgesBirthPosition: function() { var parentCoords = this.getParentScreenCoords(); _.each(this.get('outgoingEdges'), function(edge) { @@ -611,10 +618,10 @@ var VisEdge = Backbone.Model.extend({ animateUpdatedPath: function(speed, easing) { var attr = this.getAttributes(); - this.animateFromAttributes(speed, easing, attr); + this.animateFromAttr(attr, speed, easing); }, - animateFromAttributes: function(speed, easing, attr) { + animateFromAttr: function(attr, speed, easing) { this.get('path').toBack(); this.get('path').stop().animate( attr.path, diff --git a/todo.txt b/todo.txt index 6428fd14..b85a8ace 100644 --- a/todo.txt +++ b/todo.txt @@ -1,9 +1,3 @@ -The Tree.Snapshot() idea - - -TERMINAL IS DONEEeeeee :DDD - - closures on animations with those snapshots integrate animation into all git commands