animation work

This commit is contained in:
Peter Cottle 2013-06-04 10:26:50 -10:00
parent 2ba6065a0d
commit 880e1ca630
5 changed files with 82 additions and 47 deletions

View file

@ -7318,7 +7318,7 @@ GitEngine.prototype.makeOrigin = function(treeString) {
// TODO handle the case where the master target on origin is not present // TODO handle the case where the master target on origin is not present
// locally, so we have to go up the chain. for now we assume the master on // locally, so we have to go up the chain. for now we assume the master on
// origin is at least present // origin is at least present.
var originTree = JSON.parse(unescape(treeString)); var originTree = JSON.parse(unescape(treeString));
var originMasterTarget = originTree.branches.master.target; var originMasterTarget = originTree.branches.master.target;
var originMaster = this.makeBranch( var originMaster = this.makeBranch(
@ -7676,20 +7676,16 @@ GitEngine.prototype.revert = function(whichCommits) {
_.each(toRebase, function(oldCommit) { _.each(toRebase, function(oldCommit) {
var newId = this.rebaseAltID(oldCommit.get('id')); var newId = this.rebaseAltID(oldCommit.get('id'));
var commitMessage = intl.str( var commitMessage = intl.str('git-revert-msg', {
'git-revert-msg', oldCommit: this.resolveName(oldCommit),
{ oldMsg: oldCommit.get('commitMessage')
oldCommit: this.resolveName(oldCommit), });
oldMsg: oldCommit.get('commitMessage')
}
);
var newCommit = this.makeCommit([base], newId, { var newCommit = this.makeCommit([base], newId, {
commitMessage: commitMessage commitMessage: commitMessage
}); });
base = newCommit; base = newCommit;
// animation stuff // animation stuff
afterSnapshot = this.gitVisuals.genSnapshot(); afterSnapshot = this.gitVisuals.genSnapshot();
animationResponse.rebaseSteps.push({ animationResponse.rebaseSteps.push({
@ -9190,6 +9186,18 @@ var makeCommitBirthAnimation = function(gitVisuals, visNode) {
}; };
}; };
var makeHighlightAnimation = function(visNode, visBranch) {
var fullTime = GRAPHICS.defaultAnimationTime * 0.66;
var slowTime = fullTime * 2.0;
return {
animation: function() {
visNode.highlightTo(visBranch, slowTime, 'easeInOut');
},
duration: fullTime * 1.5
};
};
AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, commit, gitVisuals) { AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, commit, gitVisuals) {
if (!animationQueue) { if (!animationQueue) {
throw new Error("Need animation queue to add closure to!"); throw new Error("Need animation queue to add closure to!");
@ -9306,13 +9314,11 @@ AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebase
_.each(oldCommits, function(oldCommit) { _.each(oldCommits, function(oldCommit) {
var visNode = oldCommit.get('visNode'); var visNode = oldCommit.get('visNode');
var anPack = makeHighlightAnimation(visNode, visBranch);
animationQueue.add(new Animation({ animationQueue.add(new Animation({
closure: function() { closure: anPack.animation,
visNode.highlightTo(visBranch, slowTime, 'easeInOut'); duration: anPack.duration
},
duration: fullTime * 1.5
})); }));
}, this); }, this);
this.delay(animationQueue, fullTime * 2); this.delay(animationQueue, fullTime * 2);
@ -23248,7 +23254,7 @@ GitEngine.prototype.makeOrigin = function(treeString) {
// TODO handle the case where the master target on origin is not present // TODO handle the case where the master target on origin is not present
// locally, so we have to go up the chain. for now we assume the master on // locally, so we have to go up the chain. for now we assume the master on
// origin is at least present // origin is at least present.
var originTree = JSON.parse(unescape(treeString)); var originTree = JSON.parse(unescape(treeString));
var originMasterTarget = originTree.branches.master.target; var originMasterTarget = originTree.branches.master.target;
var originMaster = this.makeBranch( var originMaster = this.makeBranch(
@ -23606,20 +23612,16 @@ GitEngine.prototype.revert = function(whichCommits) {
_.each(toRebase, function(oldCommit) { _.each(toRebase, function(oldCommit) {
var newId = this.rebaseAltID(oldCommit.get('id')); var newId = this.rebaseAltID(oldCommit.get('id'));
var commitMessage = intl.str( var commitMessage = intl.str('git-revert-msg', {
'git-revert-msg', oldCommit: this.resolveName(oldCommit),
{ oldMsg: oldCommit.get('commitMessage')
oldCommit: this.resolveName(oldCommit), });
oldMsg: oldCommit.get('commitMessage')
}
);
var newCommit = this.makeCommit([base], newId, { var newCommit = this.makeCommit([base], newId, {
commitMessage: commitMessage commitMessage: commitMessage
}); });
base = newCommit; base = newCommit;
// animation stuff // animation stuff
afterSnapshot = this.gitVisuals.genSnapshot(); afterSnapshot = this.gitVisuals.genSnapshot();
animationResponse.rebaseSteps.push({ animationResponse.rebaseSteps.push({
@ -31323,6 +31325,18 @@ var makeCommitBirthAnimation = function(gitVisuals, visNode) {
}; };
}; };
var makeHighlightAnimation = function(visNode, visBranch) {
var fullTime = GRAPHICS.defaultAnimationTime * 0.66;
var slowTime = fullTime * 2.0;
return {
animation: function() {
visNode.highlightTo(visBranch, slowTime, 'easeInOut');
},
duration: fullTime * 1.5
};
};
AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, commit, gitVisuals) { AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, commit, gitVisuals) {
if (!animationQueue) { if (!animationQueue) {
throw new Error("Need animation queue to add closure to!"); throw new Error("Need animation queue to add closure to!");
@ -31439,13 +31453,11 @@ AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebase
_.each(oldCommits, function(oldCommit) { _.each(oldCommits, function(oldCommit) {
var visNode = oldCommit.get('visNode'); var visNode = oldCommit.get('visNode');
var anPack = makeHighlightAnimation(visNode, visBranch);
animationQueue.add(new Animation({ animationQueue.add(new Animation({
closure: function() { closure: anPack.animation,
visNode.highlightTo(visBranch, slowTime, 'easeInOut'); duration: anPack.duration
},
duration: fullTime * 1.5
})); }));
}, this); }, this);
this.delay(animationQueue, fullTime * 2); this.delay(animationQueue, fullTime * 2);

View file

@ -18,6 +18,15 @@ describe('Promise animation', function() {
expect(value).toBe(1); expect(value).toBe(1);
}); });
it('also takes animation packs', function() {
var value = 0;
var animation = new PromiseAnimation({
animation: function() { value++; }
});
animation.play();
expect(value).toBe(1);
});
it('Will resolve a deferred', function() { it('Will resolve a deferred', function() {
var value = 0; var value = 0;
var closure = function() { var closure = function() {

View file

@ -623,20 +623,16 @@ GitEngine.prototype.revert = function(whichCommits) {
_.each(toRebase, function(oldCommit) { _.each(toRebase, function(oldCommit) {
var newId = this.rebaseAltID(oldCommit.get('id')); var newId = this.rebaseAltID(oldCommit.get('id'));
var commitMessage = intl.str( var commitMessage = intl.str('git-revert-msg', {
'git-revert-msg', oldCommit: this.resolveName(oldCommit),
{ oldMsg: oldCommit.get('commitMessage')
oldCommit: this.resolveName(oldCommit), });
oldMsg: oldCommit.get('commitMessage')
}
);
var newCommit = this.makeCommit([base], newId, { var newCommit = this.makeCommit([base], newId, {
commitMessage: commitMessage commitMessage: commitMessage
}); });
base = newCommit; base = newCommit;
// animation stuff // animation stuff
afterSnapshot = this.gitVisuals.genSnapshot(); afterSnapshot = this.gitVisuals.genSnapshot();
animationResponse.rebaseSteps.push({ animationResponse.rebaseSteps.push({

View file

@ -41,6 +41,18 @@ var makeCommitBirthAnimation = function(gitVisuals, visNode) {
}; };
}; };
var makeHighlightAnimation = function(visNode, visBranch) {
var fullTime = GRAPHICS.defaultAnimationTime * 0.66;
var slowTime = fullTime * 2.0;
return {
animation: function() {
visNode.highlightTo(visBranch, slowTime, 'easeInOut');
},
duration: fullTime * 1.5
};
};
AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, commit, gitVisuals) { AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, commit, gitVisuals) {
if (!animationQueue) { if (!animationQueue) {
throw new Error("Need animation queue to add closure to!"); throw new Error("Need animation queue to add closure to!");
@ -143,9 +155,6 @@ AnimationFactory.prototype.rebaseAnimation = function(animationQueue, rebaseResp
}; };
AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebaseResponse, gitEngine) { AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebaseResponse, gitEngine) {
var fullTime = GRAPHICS.defaultAnimationTime * 0.66;
var slowTime = fullTime * 2.0;
// we want to highlight all the old commits // we want to highlight all the old commits
var oldCommits = rebaseResponse.toRebaseArray; var oldCommits = rebaseResponse.toRebaseArray;
// we are either highlighting to a visBranch or a visNode // we are either highlighting to a visBranch or a visNode
@ -157,18 +166,27 @@ AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebase
_.each(oldCommits, function(oldCommit) { _.each(oldCommits, function(oldCommit) {
var visNode = oldCommit.get('visNode'); var visNode = oldCommit.get('visNode');
var anPack = makeHighlightAnimation(visNode, visBranch);
animationQueue.add(new Animation({ animationQueue.add(new Animation({
closure: function() { closure: anPack.animation,
visNode.highlightTo(visBranch, slowTime, 'easeInOut'); duration: anPack.duration
},
duration: fullTime * 1.5
})); }));
}, this); }, this);
this.delay(animationQueue, fullTime * 2); this.delay(animationQueue, fullTime * 2);
}; };
AnimationFactory.prototype.genHighlightPromiseAnmation = function(commit, destBranch) {
var visBranch = destBranch.get('visBranch');
var visNode = commit.get('visNode');
var anPack = makeHighlightAnimation(visNode, visBranch);
return new PromiseAnimation({
closure: anPack.animation,
duration: anPack.duration
});
};
AnimationFactory.prototype.rebaseBirthPart = function(animationQueue, rebaseResponse, AnimationFactory.prototype.rebaseBirthPart = function(animationQueue, rebaseResponse,
gitEngine, gitVisuals) { gitEngine, gitVisuals) {
var rebaseSteps = rebaseResponse.rebaseSteps; var rebaseSteps = rebaseResponse.rebaseSteps;

View file

@ -103,10 +103,10 @@ var PromiseAnimation = Backbone.Model.extend({
}, },
initialize: function(options) { initialize: function(options) {
if (!options.closure) { if (!options.closure && !options.animation) {
throw new Error('need closure'); throw new Error('need closure or animation');
} }
// TODO needed? this.set('closure', options.closure || options.animation);
this.set('deferred', options.deferred || Q.defer()); this.set('deferred', options.deferred || Q.defer());
}, },