mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 16:38:50 +02:00
weird part with rebase animation
This commit is contained in:
parent
01b9b1132d
commit
1bbdb5d6a0
4 changed files with 80 additions and 6 deletions
|
@ -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();
|
||||
}
|
||||
}));
|
||||
};
|
||||
|
||||
|
|
42
src/git.js
42
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() {
|
||||
|
|
|
@ -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);
|
||||
|
|
5
todo.txt
5
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue