big finish on the rebase animation

This commit is contained in:
Peter Cottle 2012-09-30 16:30:43 -07:00
parent b106e22ac3
commit 311e429ba3
4 changed files with 59 additions and 49 deletions

View file

@ -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) {

View file

@ -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
}));
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);
// first set all birth positions...
_.each(response, function(step) {
step.newCommit.get('visNode').setBirth();
}, this);
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() {

View file

@ -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,

View file

@ -1,9 +1,3 @@
The Tree.Snapshot() idea
TERMINAL IS DONEEeeeee :DDD
closures on animations with those snapshots
integrate animation into all git commands