mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 07:58:34 +02:00
animation work
This commit is contained in:
parent
2ba6065a0d
commit
880e1ca630
5 changed files with 82 additions and 47 deletions
|
@ -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);
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue