weird part with rebase animation

This commit is contained in:
Peter Cottle 2012-09-30 14:57:49 -07:00
parent 01b9b1132d
commit 1bbdb5d6a0
4 changed files with 80 additions and 6 deletions

View file

@ -28,8 +28,7 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co
// this takes care of refs and all that jazz, and updates all the positions // this takes care of refs and all that jazz, and updates all the positions
gitVisuals.refreshTree(time); gitVisuals.refreshTree(time);
visNode.setBirthPosition(); visNode.setBirth();
visNode.setOutgoingEdgesBirthPosition();
visNode.parentInFront(); visNode.parentInFront();
visNode.animateUpdatedPosition(bounceTime, 'bounce'); visNode.animateUpdatedPosition(bounceTime, 'bounce');
@ -41,3 +40,34 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co
duration: Math.max(time, bounceTime) 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();
}
}));
};

View file

@ -482,7 +482,39 @@ GitEngine.prototype.rebaseStarter = function() {
if (this.generalArgs.length == 1) { if (this.generalArgs.length == 1) {
this.generalArgs.push('HEAD'); 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) { 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. // 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 // 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 // pop these commits on top of targetSource and modify their ids with quotes
var stopSet = this.getUpstreamSet(targetSource) var stopSet = this.getUpstreamSet(targetSource)
// now BFS from here on out // now BFS from here on out
@ -541,16 +572,21 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) {
// now pop all of these commits onto targetLocation // now pop all of these commits onto targetLocation
var base = this.getCommitFromRef(targetSource); var base = this.getCommitFromRef(targetSource);
var newCommits = [];
for (var i = 0; i < toRebase.length; i++) { for (var i = 0; i < toRebase.length; i++) {
var old = toRebase[i]; var old = toRebase[i];
var newId = this.rebaseAltId(old.get('id')); var newId = this.rebaseAltId(old.get('id'));
var newCommit = this.makeCommit([base], newId); var newCommit = this.makeCommit([base], newId);
newCommits.push(newCommit);
base = newCommit; base = newCommit;
} }
// now we just need to update where we are // now we just need to update where we are
this.setLocationTarget(currentLocation, base); this.setLocationTarget(currentLocation, base);
// done! haha
// for animation
return newCommits;
}; };
GitEngine.prototype.mergeStarter = function() { GitEngine.prototype.mergeStarter = function() {

View file

@ -430,6 +430,11 @@ var VisNode = Backbone.Model.extend({
}); });
}, },
setBirth: function() {
this.setBirthPosition();
this.setOutgoingEdgesBirthPosition();
},
animateOutgoingEdges: function(speed, easing) { animateOutgoingEdges: function(speed, easing) {
_.each(this.get('outgoingEdges'), function(edge) { _.each(this.get('outgoingEdges'), function(edge) {
edge.animateUpdatedPath(speed, easing); edge.animateUpdatedPath(speed, easing);

View file

@ -1,7 +1,10 @@
The Tree.Snapshot() idea 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 integrate animation into all git commands
animation factory? stuff like: animation factory? stuff like: