diff --git a/src/animationFactory.js b/src/animationFactory.js index 5e9155cd..021268a9 100644 --- a/src/animationFactory.js +++ b/src/animationFactory.js @@ -28,8 +28,7 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co // this takes care of refs and all that jazz, and updates all the positions gitVisuals.refreshTree(time); - visNode.setBirthPosition(); - visNode.setOutgoingEdgesBirthPosition(); + visNode.setBirth(); visNode.parentInFront(); visNode.animateUpdatedPosition(bounceTime, 'bounce'); @@ -41,3 +40,34 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co duration: Math.max(time, bounceTime) })); }; + +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) { + animationQueue.add(new Animation({ + closure: function() { + console.log('refreshing tree from here'); + gitVisuals.refreshTree(); + } + })); +}; + diff --git a/src/git.js b/src/git.js index 10859879..0c5b9c5b 100644 --- a/src/git.js +++ b/src/git.js @@ -482,7 +482,39 @@ GitEngine.prototype.rebaseStarter = function() { if (this.generalArgs.length == 1) { this.generalArgs.push('HEAD'); } - this.rebase(this.generalArgs[0], this.generalArgs[1]); + var response = this.rebase(this.generalArgs[0], this.generalArgs[1]); + if (response === undefined) { + // 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(); + }); + }; + + this.animationQueue.add(new Animation({ + closure: start + })); + + 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); + } + + animationFactory.refreshTree(this.animationQueue); }; GitEngine.prototype.rebase = function(targetSource, currentLocation) { @@ -506,7 +538,6 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) { // then we BFS from currentLocation, using the downstream set as our stopping point. // we need to BFS because we need to include all commits below // pop these commits on top of targetSource and modify their ids with quotes - var stopSet = this.getUpstreamSet(targetSource) // now BFS from here on out @@ -541,16 +572,21 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) { // now pop all of these commits onto targetLocation var base = this.getCommitFromRef(targetSource); + var newCommits = []; + 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; } // now we just need to update where we are this.setLocationTarget(currentLocation, base); - // done! haha + + // for animation + return newCommits; }; GitEngine.prototype.mergeStarter = function() { diff --git a/src/tree.js b/src/tree.js index 1e08da9f..46a941a4 100644 --- a/src/tree.js +++ b/src/tree.js @@ -430,6 +430,11 @@ var VisNode = Backbone.Model.extend({ }); }, + setBirth: function() { + this.setBirthPosition(); + this.setOutgoingEdgesBirthPosition(); + }, + animateOutgoingEdges: function(speed, easing) { _.each(this.get('outgoingEdges'), function(edge) { edge.animateUpdatedPath(speed, easing); diff --git a/todo.txt b/todo.txt index 4866b859..6428fd14 100644 --- a/todo.txt +++ b/todo.txt @@ -1,7 +1,10 @@ The Tree.Snapshot() idea -closures on animations with those snapshots +TERMINAL IS DONEEeeeee :DDD + + +closures on animations with those snapshots integrate animation into all git commands animation factory? stuff like: