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
// 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 originMasterTarget = originTree.branches.master.target;
var originMaster = this.makeBranch(
@ -7676,20 +7676,16 @@ GitEngine.prototype.revert = function(whichCommits) {
_.each(toRebase, function(oldCommit) {
var newId = this.rebaseAltID(oldCommit.get('id'));
var commitMessage = intl.str(
'git-revert-msg',
{
var commitMessage = intl.str('git-revert-msg', {
oldCommit: this.resolveName(oldCommit),
oldMsg: oldCommit.get('commitMessage')
}
);
});
var newCommit = this.makeCommit([base], newId, {
commitMessage: commitMessage
});
base = newCommit;
// animation stuff
afterSnapshot = this.gitVisuals.genSnapshot();
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) {
if (!animationQueue) {
throw new Error("Need animation queue to add closure to!");
@ -9306,13 +9314,11 @@ AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebase
_.each(oldCommits, function(oldCommit) {
var visNode = oldCommit.get('visNode');
var anPack = makeHighlightAnimation(visNode, visBranch);
animationQueue.add(new Animation({
closure: function() {
visNode.highlightTo(visBranch, slowTime, 'easeInOut');
},
duration: fullTime * 1.5
closure: anPack.animation,
duration: anPack.duration
}));
}, this);
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
// 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 originMasterTarget = originTree.branches.master.target;
var originMaster = this.makeBranch(
@ -23606,20 +23612,16 @@ GitEngine.prototype.revert = function(whichCommits) {
_.each(toRebase, function(oldCommit) {
var newId = this.rebaseAltID(oldCommit.get('id'));
var commitMessage = intl.str(
'git-revert-msg',
{
var commitMessage = intl.str('git-revert-msg', {
oldCommit: this.resolveName(oldCommit),
oldMsg: oldCommit.get('commitMessage')
}
);
});
var newCommit = this.makeCommit([base], newId, {
commitMessage: commitMessage
});
base = newCommit;
// animation stuff
afterSnapshot = this.gitVisuals.genSnapshot();
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) {
if (!animationQueue) {
throw new Error("Need animation queue to add closure to!");
@ -31439,13 +31453,11 @@ AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebase
_.each(oldCommits, function(oldCommit) {
var visNode = oldCommit.get('visNode');
var anPack = makeHighlightAnimation(visNode, visBranch);
animationQueue.add(new Animation({
closure: function() {
visNode.highlightTo(visBranch, slowTime, 'easeInOut');
},
duration: fullTime * 1.5
closure: anPack.animation,
duration: anPack.duration
}));
}, this);
this.delay(animationQueue, fullTime * 2);

View file

@ -18,6 +18,15 @@ describe('Promise animation', function() {
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() {
var value = 0;
var closure = function() {

View file

@ -623,20 +623,16 @@ GitEngine.prototype.revert = function(whichCommits) {
_.each(toRebase, function(oldCommit) {
var newId = this.rebaseAltID(oldCommit.get('id'));
var commitMessage = intl.str(
'git-revert-msg',
{
var commitMessage = intl.str('git-revert-msg', {
oldCommit: this.resolveName(oldCommit),
oldMsg: oldCommit.get('commitMessage')
}
);
});
var newCommit = this.makeCommit([base], newId, {
commitMessage: commitMessage
});
base = newCommit;
// animation stuff
afterSnapshot = this.gitVisuals.genSnapshot();
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) {
if (!animationQueue) {
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) {
var fullTime = GRAPHICS.defaultAnimationTime * 0.66;
var slowTime = fullTime * 2.0;
// we want to highlight all the old commits
var oldCommits = rebaseResponse.toRebaseArray;
// we are either highlighting to a visBranch or a visNode
@ -157,18 +166,27 @@ AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebase
_.each(oldCommits, function(oldCommit) {
var visNode = oldCommit.get('visNode');
var anPack = makeHighlightAnimation(visNode, visBranch);
animationQueue.add(new Animation({
closure: function() {
visNode.highlightTo(visBranch, slowTime, 'easeInOut');
},
duration: fullTime * 1.5
closure: anPack.animation,
duration: anPack.duration
}));
}, this);
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,
gitEngine, gitVisuals) {
var rebaseSteps = rebaseResponse.rebaseSteps;

View file

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