mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-10 14:44:28 +02:00
in the midle of teamwork reorg why does promise not defer?
This commit is contained in:
parent
292126437a
commit
bf6f987482
4 changed files with 129 additions and 58 deletions
124
build/bundle.js
124
build/bundle.js
|
@ -7890,15 +7890,19 @@ GitEngine.prototype.fakeTeamworkStarter = function() {
|
||||||
GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
||||||
var makeOriginCommit = _.bind(function() {
|
var makeOriginCommit = _.bind(function() {
|
||||||
var id = this.getUniqueID();
|
var id = this.getUniqueID();
|
||||||
this.origin.receiveTeamwork(id, this.animationQueue);
|
return this.origin.receiveTeamwork(id, this.animationQueue);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
var chainStep = function() {
|
var chainStep = _.bind(function() {
|
||||||
makeOriginCommit();
|
var newCommit = makeOriginCommit();
|
||||||
var d = Q.defer();
|
var animation = this.animationFactory.genCommitBirthPromiseAnimation(
|
||||||
setTimeout(function() { d.resolve(); }, 1000);
|
newCommit,
|
||||||
return d.promise;
|
this.origin.gitVisuals
|
||||||
};
|
);
|
||||||
|
animation.play();
|
||||||
|
console.log('playing animation');
|
||||||
|
return animation.getPromise();
|
||||||
|
}, this);
|
||||||
|
|
||||||
var deferred = Q.defer();
|
var deferred = Q.defer();
|
||||||
var chain = deferred.promise;
|
var chain = deferred.promise;
|
||||||
|
@ -7918,7 +7922,6 @@ GitEngine.prototype.receiveTeamwork = function(id, animationQueue) {
|
||||||
var newCommit = this.makeCommit([this.getCommitFromRef('HEAD')], id);
|
var newCommit = this.makeCommit([this.getCommitFromRef('HEAD')], id);
|
||||||
this.setTargetLocation(this.HEAD, newCommit);
|
this.setTargetLocation(this.HEAD, newCommit);
|
||||||
|
|
||||||
//this.animationFactory.genCommitBirthAnimation(animationQueue, newCommit, this.gitVisuals);
|
|
||||||
return newCommit;
|
return newCommit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9143,6 +9146,7 @@ require.define("/src/js/visuals/animation/animationFactory.js",function(require,
|
||||||
var Backbone = require('backbone');
|
var Backbone = require('backbone');
|
||||||
|
|
||||||
var Animation = require('./index').Animation;
|
var Animation = require('./index').Animation;
|
||||||
|
var PromiseAnimation = require('./index').PromiseAnimation;
|
||||||
var GRAPHICS = require('../../util/constants').GRAPHICS;
|
var GRAPHICS = require('../../util/constants').GRAPHICS;
|
||||||
|
|
||||||
/******************
|
/******************
|
||||||
|
@ -9160,19 +9164,12 @@ var AnimationFactory = function() {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, commit, gitVisuals) {
|
var makeCommitBirthAnimation = function(gitVisuals, visNode) {
|
||||||
if (!animationQueue) {
|
|
||||||
throw new Error("Need animation queue to add closure to!");
|
|
||||||
}
|
|
||||||
|
|
||||||
var time = GRAPHICS.defaultAnimationTime * 1.0;
|
var time = GRAPHICS.defaultAnimationTime * 1.0;
|
||||||
var bounceTime = time * 2;
|
var bounceTime = time * 2;
|
||||||
|
|
||||||
// essentially refresh the entire tree, but do a special thing for the commit
|
|
||||||
var visNode = commit.get('visNode');
|
|
||||||
|
|
||||||
var animation = function() {
|
var animation = function() {
|
||||||
// this takes care of refs and all that jazz, and updates all the positions
|
// essentially refresh the entire tree, but do a special thing for the commit
|
||||||
gitVisuals.refreshTree(time);
|
gitVisuals.refreshTree(time);
|
||||||
|
|
||||||
visNode.setBirth();
|
visNode.setBirth();
|
||||||
|
@ -9182,13 +9179,36 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co
|
||||||
visNode.animateUpdatedPosition(bounceTime, 'bounce');
|
visNode.animateUpdatedPosition(bounceTime, 'bounce');
|
||||||
visNode.animateOutgoingEdges(time);
|
visNode.animateOutgoingEdges(time);
|
||||||
};
|
};
|
||||||
|
return {
|
||||||
|
animation: animation,
|
||||||
|
duration: Math.max(time, bounceTime)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, commit, gitVisuals) {
|
||||||
|
if (!animationQueue) {
|
||||||
|
throw new Error("Need animation queue to add closure to!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var visNode = commit.get('visNode');
|
||||||
|
var anPack = makeCommitBirthAnimation(gitVisuals, visNode);
|
||||||
|
|
||||||
animationQueue.add(new Animation({
|
animationQueue.add(new Animation({
|
||||||
closure: animation,
|
closure: anPack.animation,
|
||||||
duration: Math.max(time, bounceTime)
|
duration: anPack.duration
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) {
|
||||||
|
var visNode = commit.get('visNode');
|
||||||
|
var anPack = makeCommitBirthAnimation(gitVisuals, visNode);
|
||||||
|
console.log('my duration', anPack.duration);
|
||||||
|
return new PromiseAnimation({
|
||||||
|
closure: anPack.animation,
|
||||||
|
duration: anPack.duration
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
AnimationFactory.prototype.overrideOpacityDepth2 = function(attr, opacity) {
|
AnimationFactory.prototype.overrideOpacityDepth2 = function(attr, opacity) {
|
||||||
opacity = (opacity === undefined) ? 1 : opacity;
|
opacity = (opacity === undefined) ? 1 : opacity;
|
||||||
|
|
||||||
|
@ -9505,6 +9525,10 @@ var PromiseAnimation = Backbone.Model.extend({
|
||||||
this.set('deferred', options.deferred || Q.defer());
|
this.set('deferred', options.deferred || Q.defer());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getPromise: function() {
|
||||||
|
return this.get('deferred').promise;
|
||||||
|
},
|
||||||
|
|
||||||
play: function() {
|
play: function() {
|
||||||
// a single animation is just something with a timeout, but now
|
// a single animation is just something with a timeout, but now
|
||||||
// we want to resolve a deferred when the animation finishes
|
// we want to resolve a deferred when the animation finishes
|
||||||
|
@ -23768,15 +23792,19 @@ GitEngine.prototype.fakeTeamworkStarter = function() {
|
||||||
GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
||||||
var makeOriginCommit = _.bind(function() {
|
var makeOriginCommit = _.bind(function() {
|
||||||
var id = this.getUniqueID();
|
var id = this.getUniqueID();
|
||||||
this.origin.receiveTeamwork(id, this.animationQueue);
|
return this.origin.receiveTeamwork(id, this.animationQueue);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
var chainStep = function() {
|
var chainStep = _.bind(function() {
|
||||||
makeOriginCommit();
|
var newCommit = makeOriginCommit();
|
||||||
var d = Q.defer();
|
var animation = this.animationFactory.genCommitBirthPromiseAnimation(
|
||||||
setTimeout(function() { d.resolve(); }, 1000);
|
newCommit,
|
||||||
return d.promise;
|
this.origin.gitVisuals
|
||||||
};
|
);
|
||||||
|
animation.play();
|
||||||
|
console.log('playing animation');
|
||||||
|
return animation.getPromise();
|
||||||
|
}, this);
|
||||||
|
|
||||||
var deferred = Q.defer();
|
var deferred = Q.defer();
|
||||||
var chain = deferred.promise;
|
var chain = deferred.promise;
|
||||||
|
@ -23796,7 +23824,6 @@ GitEngine.prototype.receiveTeamwork = function(id, animationQueue) {
|
||||||
var newCommit = this.makeCommit([this.getCommitFromRef('HEAD')], id);
|
var newCommit = this.makeCommit([this.getCommitFromRef('HEAD')], id);
|
||||||
this.setTargetLocation(this.HEAD, newCommit);
|
this.setTargetLocation(this.HEAD, newCommit);
|
||||||
|
|
||||||
//this.animationFactory.genCommitBirthAnimation(animationQueue, newCommit, this.gitVisuals);
|
|
||||||
return newCommit;
|
return newCommit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31224,6 +31251,7 @@ require.define("/src/js/visuals/animation/animationFactory.js",function(require,
|
||||||
var Backbone = require('backbone');
|
var Backbone = require('backbone');
|
||||||
|
|
||||||
var Animation = require('./index').Animation;
|
var Animation = require('./index').Animation;
|
||||||
|
var PromiseAnimation = require('./index').PromiseAnimation;
|
||||||
var GRAPHICS = require('../../util/constants').GRAPHICS;
|
var GRAPHICS = require('../../util/constants').GRAPHICS;
|
||||||
|
|
||||||
/******************
|
/******************
|
||||||
|
@ -31241,19 +31269,12 @@ var AnimationFactory = function() {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, commit, gitVisuals) {
|
var makeCommitBirthAnimation = function(gitVisuals, visNode) {
|
||||||
if (!animationQueue) {
|
|
||||||
throw new Error("Need animation queue to add closure to!");
|
|
||||||
}
|
|
||||||
|
|
||||||
var time = GRAPHICS.defaultAnimationTime * 1.0;
|
var time = GRAPHICS.defaultAnimationTime * 1.0;
|
||||||
var bounceTime = time * 2;
|
var bounceTime = time * 2;
|
||||||
|
|
||||||
// essentially refresh the entire tree, but do a special thing for the commit
|
|
||||||
var visNode = commit.get('visNode');
|
|
||||||
|
|
||||||
var animation = function() {
|
var animation = function() {
|
||||||
// this takes care of refs and all that jazz, and updates all the positions
|
// essentially refresh the entire tree, but do a special thing for the commit
|
||||||
gitVisuals.refreshTree(time);
|
gitVisuals.refreshTree(time);
|
||||||
|
|
||||||
visNode.setBirth();
|
visNode.setBirth();
|
||||||
|
@ -31263,13 +31284,36 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co
|
||||||
visNode.animateUpdatedPosition(bounceTime, 'bounce');
|
visNode.animateUpdatedPosition(bounceTime, 'bounce');
|
||||||
visNode.animateOutgoingEdges(time);
|
visNode.animateOutgoingEdges(time);
|
||||||
};
|
};
|
||||||
|
return {
|
||||||
|
animation: animation,
|
||||||
|
duration: Math.max(time, bounceTime)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, commit, gitVisuals) {
|
||||||
|
if (!animationQueue) {
|
||||||
|
throw new Error("Need animation queue to add closure to!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var visNode = commit.get('visNode');
|
||||||
|
var anPack = makeCommitBirthAnimation(gitVisuals, visNode);
|
||||||
|
|
||||||
animationQueue.add(new Animation({
|
animationQueue.add(new Animation({
|
||||||
closure: animation,
|
closure: anPack.animation,
|
||||||
duration: Math.max(time, bounceTime)
|
duration: anPack.duration
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) {
|
||||||
|
var visNode = commit.get('visNode');
|
||||||
|
var anPack = makeCommitBirthAnimation(gitVisuals, visNode);
|
||||||
|
console.log('my duration', anPack.duration);
|
||||||
|
return new PromiseAnimation({
|
||||||
|
closure: anPack.animation,
|
||||||
|
duration: anPack.duration
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
AnimationFactory.prototype.overrideOpacityDepth2 = function(attr, opacity) {
|
AnimationFactory.prototype.overrideOpacityDepth2 = function(attr, opacity) {
|
||||||
opacity = (opacity === undefined) ? 1 : opacity;
|
opacity = (opacity === undefined) ? 1 : opacity;
|
||||||
|
|
||||||
|
@ -31587,6 +31631,10 @@ var PromiseAnimation = Backbone.Model.extend({
|
||||||
this.set('deferred', options.deferred || Q.defer());
|
this.set('deferred', options.deferred || Q.defer());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getPromise: function() {
|
||||||
|
return this.get('deferred').promise;
|
||||||
|
},
|
||||||
|
|
||||||
play: function() {
|
play: function() {
|
||||||
// a single animation is just something with a timeout, but now
|
// a single animation is just something with a timeout, but now
|
||||||
// we want to resolve a deferred when the animation finishes
|
// we want to resolve a deferred when the animation finishes
|
||||||
|
|
|
@ -44,7 +44,7 @@ GitEngine.prototype.initUniqueID = function() {
|
||||||
this.uniqueId = (function() {
|
this.uniqueId = (function() {
|
||||||
var n = 0;
|
var n = 0;
|
||||||
return function(prepend) {
|
return function(prepend) {
|
||||||
return prepend? prepend + n++ : n++;
|
return prepend ? prepend + n++ : n++;
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
};
|
};
|
||||||
|
@ -837,15 +837,18 @@ GitEngine.prototype.fakeTeamworkStarter = function() {
|
||||||
GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
||||||
var makeOriginCommit = _.bind(function() {
|
var makeOriginCommit = _.bind(function() {
|
||||||
var id = this.getUniqueID();
|
var id = this.getUniqueID();
|
||||||
this.origin.receiveTeamwork(id, this.animationQueue);
|
return this.origin.receiveTeamwork(id, this.animationQueue);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
var chainStep = function() {
|
var chainStep = _.bind(function() {
|
||||||
makeOriginCommit();
|
var newCommit = makeOriginCommit();
|
||||||
var d = Q.defer();
|
var animation = this.animationFactory.genCommitBirthPromiseAnimation(
|
||||||
setTimeout(function() { d.resolve(); }, 1000);
|
newCommit,
|
||||||
return d.promise;
|
this.origin.gitVisuals
|
||||||
};
|
);
|
||||||
|
animation.play();
|
||||||
|
return animation.getPromise();
|
||||||
|
}, this);
|
||||||
|
|
||||||
var deferred = Q.defer();
|
var deferred = Q.defer();
|
||||||
var chain = deferred.promise;
|
var chain = deferred.promise;
|
||||||
|
@ -865,7 +868,6 @@ GitEngine.prototype.receiveTeamwork = function(id, animationQueue) {
|
||||||
var newCommit = this.makeCommit([this.getCommitFromRef('HEAD')], id);
|
var newCommit = this.makeCommit([this.getCommitFromRef('HEAD')], id);
|
||||||
this.setTargetLocation(this.HEAD, newCommit);
|
this.setTargetLocation(this.HEAD, newCommit);
|
||||||
|
|
||||||
//this.animationFactory.genCommitBirthAnimation(animationQueue, newCommit, this.gitVisuals);
|
|
||||||
return newCommit;
|
return newCommit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ var _ = require('underscore');
|
||||||
var Backbone = require('backbone');
|
var Backbone = require('backbone');
|
||||||
|
|
||||||
var Animation = require('./index').Animation;
|
var Animation = require('./index').Animation;
|
||||||
|
var PromiseAnimation = require('./index').PromiseAnimation;
|
||||||
var GRAPHICS = require('../../util/constants').GRAPHICS;
|
var GRAPHICS = require('../../util/constants').GRAPHICS;
|
||||||
|
|
||||||
/******************
|
/******************
|
||||||
|
@ -19,19 +20,12 @@ var AnimationFactory = function() {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, commit, gitVisuals) {
|
var makeCommitBirthAnimation = function(gitVisuals, visNode) {
|
||||||
if (!animationQueue) {
|
|
||||||
throw new Error("Need animation queue to add closure to!");
|
|
||||||
}
|
|
||||||
|
|
||||||
var time = GRAPHICS.defaultAnimationTime * 1.0;
|
var time = GRAPHICS.defaultAnimationTime * 1.0;
|
||||||
var bounceTime = time * 2;
|
var bounceTime = time * 2;
|
||||||
|
|
||||||
// essentially refresh the entire tree, but do a special thing for the commit
|
|
||||||
var visNode = commit.get('visNode');
|
|
||||||
|
|
||||||
var animation = function() {
|
var animation = function() {
|
||||||
// this takes care of refs and all that jazz, and updates all the positions
|
// essentially refresh the entire tree, but do a special thing for the commit
|
||||||
gitVisuals.refreshTree(time);
|
gitVisuals.refreshTree(time);
|
||||||
|
|
||||||
visNode.setBirth();
|
visNode.setBirth();
|
||||||
|
@ -41,13 +35,36 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co
|
||||||
visNode.animateUpdatedPosition(bounceTime, 'bounce');
|
visNode.animateUpdatedPosition(bounceTime, 'bounce');
|
||||||
visNode.animateOutgoingEdges(time);
|
visNode.animateOutgoingEdges(time);
|
||||||
};
|
};
|
||||||
|
return {
|
||||||
|
animation: animation,
|
||||||
|
duration: Math.max(time, bounceTime)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, commit, gitVisuals) {
|
||||||
|
if (!animationQueue) {
|
||||||
|
throw new Error("Need animation queue to add closure to!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var visNode = commit.get('visNode');
|
||||||
|
var anPack = makeCommitBirthAnimation(gitVisuals, visNode);
|
||||||
|
|
||||||
animationQueue.add(new Animation({
|
animationQueue.add(new Animation({
|
||||||
closure: animation,
|
closure: anPack.animation,
|
||||||
duration: Math.max(time, bounceTime)
|
duration: anPack.duration
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) {
|
||||||
|
var visNode = commit.get('visNode');
|
||||||
|
var anPack = makeCommitBirthAnimation(gitVisuals, visNode);
|
||||||
|
console.log('my duration', anPack.duration);
|
||||||
|
return new PromiseAnimation({
|
||||||
|
closure: anPack.animation,
|
||||||
|
duration: anPack.duration
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
AnimationFactory.prototype.overrideOpacityDepth2 = function(attr, opacity) {
|
AnimationFactory.prototype.overrideOpacityDepth2 = function(attr, opacity) {
|
||||||
opacity = (opacity === undefined) ? 1 : opacity;
|
opacity = (opacity === undefined) ? 1 : opacity;
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,10 @@ var PromiseAnimation = Backbone.Model.extend({
|
||||||
this.set('deferred', options.deferred || Q.defer());
|
this.set('deferred', options.deferred || Q.defer());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getPromise: function() {
|
||||||
|
return this.get('deferred').promise;
|
||||||
|
},
|
||||||
|
|
||||||
play: function() {
|
play: function() {
|
||||||
// a single animation is just something with a timeout, but now
|
// a single animation is just something with a timeout, but now
|
||||||
// we want to resolve a deferred when the animation finishes
|
// we want to resolve a deferred when the animation finishes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue