mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 07:58:34 +02:00
AWESSOMEEE now converted animation queue to promise based too
This commit is contained in:
parent
4619eb370c
commit
c8d117073f
4 changed files with 66 additions and 21 deletions
|
@ -7895,12 +7895,10 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
||||||
|
|
||||||
var chainStep = _.bind(function() {
|
var chainStep = _.bind(function() {
|
||||||
var newCommit = makeOriginCommit();
|
var newCommit = makeOriginCommit();
|
||||||
var animation = this.animationFactory.genCommitBirthPromiseAnimation(
|
return this.animationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.origin.gitVisuals
|
this.origin.gitVisuals
|
||||||
);
|
);
|
||||||
animation.play();
|
|
||||||
return animation.getPromise();
|
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
var deferred = Q.defer();
|
var deferred = Q.defer();
|
||||||
|
@ -7915,6 +7913,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
||||||
return chainStep();
|
return chainStep();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.animationQueue.thenFinish(chain);
|
||||||
|
|
||||||
deferred.resolve();
|
deferred.resolve();
|
||||||
};
|
};
|
||||||
|
@ -8817,13 +8816,16 @@ GitEngine.prototype.dispatch = function(command, deferred) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var willStartAuto = this.animationQueue.get('defer') ||
|
||||||
|
this.animationQueue.get('promiseBased');
|
||||||
|
|
||||||
// only add the refresh if we didn't do manual animations
|
// only add the refresh if we didn't do manual animations
|
||||||
if (!this.animationQueue.get('animations').length && !this.animationQueue.get('defer')) {
|
if (!this.animationQueue.get('animations').length && !willStartAuto) {
|
||||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||||
}
|
}
|
||||||
|
|
||||||
// animation queue will call the callback when its done
|
// animation queue will call the callback when its done
|
||||||
if (!this.animationQueue.get('defer')) {
|
if (!willStartAuto) {
|
||||||
this.animationQueue.start();
|
this.animationQueue.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -9203,13 +9205,18 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co
|
||||||
AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) {
|
AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) {
|
||||||
var visNode = commit.get('visNode');
|
var visNode = commit.get('visNode');
|
||||||
var anPack = makeCommitBirthAnimation(gitVisuals, visNode);
|
var anPack = makeCommitBirthAnimation(gitVisuals, visNode);
|
||||||
console.log('my duration', anPack.duration);
|
|
||||||
return new PromiseAnimation({
|
return new PromiseAnimation({
|
||||||
closure: anPack.animation,
|
closure: anPack.animation,
|
||||||
duration: anPack.duration
|
duration: anPack.duration
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) {
|
||||||
|
var animation = this.genCommitBirthPromiseAnimation(commit, gitVisuals);
|
||||||
|
animation.play();
|
||||||
|
return animation.getPromise();
|
||||||
|
};
|
||||||
|
|
||||||
AnimationFactory.prototype.overrideOpacityDepth2 = function(attr, opacity) {
|
AnimationFactory.prototype.overrideOpacityDepth2 = function(attr, opacity) {
|
||||||
opacity = (opacity === undefined) ? 1 : opacity;
|
opacity = (opacity === undefined) ? 1 : opacity;
|
||||||
|
|
||||||
|
@ -9453,7 +9460,8 @@ var AnimationQueue = Backbone.Model.extend({
|
||||||
animations: null,
|
animations: null,
|
||||||
index: 0,
|
index: 0,
|
||||||
callback: null,
|
callback: null,
|
||||||
defer: false
|
defer: false,
|
||||||
|
promiseBased: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
|
@ -9463,6 +9471,13 @@ var AnimationQueue = Backbone.Model.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
thenFinish: function(promise) {
|
||||||
|
promise.then(_.bind(function() {
|
||||||
|
this.finish();
|
||||||
|
}, this));
|
||||||
|
this.set('promiseBased', true);
|
||||||
|
},
|
||||||
|
|
||||||
add: function(animation) {
|
add: function(animation) {
|
||||||
if (!animation instanceof Animation) {
|
if (!animation instanceof Animation) {
|
||||||
throw new Error("Need animation not something else");
|
throw new Error("Need animation not something else");
|
||||||
|
@ -23798,12 +23813,10 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
||||||
|
|
||||||
var chainStep = _.bind(function() {
|
var chainStep = _.bind(function() {
|
||||||
var newCommit = makeOriginCommit();
|
var newCommit = makeOriginCommit();
|
||||||
var animation = this.animationFactory.genCommitBirthPromiseAnimation(
|
return this.animationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.origin.gitVisuals
|
this.origin.gitVisuals
|
||||||
);
|
);
|
||||||
animation.play();
|
|
||||||
return animation.getPromise();
|
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
var deferred = Q.defer();
|
var deferred = Q.defer();
|
||||||
|
@ -23818,6 +23831,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
||||||
return chainStep();
|
return chainStep();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.animationQueue.thenFinish(chain);
|
||||||
|
|
||||||
deferred.resolve();
|
deferred.resolve();
|
||||||
};
|
};
|
||||||
|
@ -24720,13 +24734,16 @@ GitEngine.prototype.dispatch = function(command, deferred) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var willStartAuto = this.animationQueue.get('defer') ||
|
||||||
|
this.animationQueue.get('promiseBased');
|
||||||
|
|
||||||
// only add the refresh if we didn't do manual animations
|
// only add the refresh if we didn't do manual animations
|
||||||
if (!this.animationQueue.get('animations').length && !this.animationQueue.get('defer')) {
|
if (!this.animationQueue.get('animations').length && !willStartAuto) {
|
||||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||||
}
|
}
|
||||||
|
|
||||||
// animation queue will call the callback when its done
|
// animation queue will call the callback when its done
|
||||||
if (!this.animationQueue.get('defer')) {
|
if (!willStartAuto) {
|
||||||
this.animationQueue.start();
|
this.animationQueue.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -31309,13 +31326,18 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co
|
||||||
AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) {
|
AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) {
|
||||||
var visNode = commit.get('visNode');
|
var visNode = commit.get('visNode');
|
||||||
var anPack = makeCommitBirthAnimation(gitVisuals, visNode);
|
var anPack = makeCommitBirthAnimation(gitVisuals, visNode);
|
||||||
console.log('my duration', anPack.duration);
|
|
||||||
return new PromiseAnimation({
|
return new PromiseAnimation({
|
||||||
closure: anPack.animation,
|
closure: anPack.animation,
|
||||||
duration: anPack.duration
|
duration: anPack.duration
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) {
|
||||||
|
var animation = this.genCommitBirthPromiseAnimation(commit, gitVisuals);
|
||||||
|
animation.play();
|
||||||
|
return animation.getPromise();
|
||||||
|
};
|
||||||
|
|
||||||
AnimationFactory.prototype.overrideOpacityDepth2 = function(attr, opacity) {
|
AnimationFactory.prototype.overrideOpacityDepth2 = function(attr, opacity) {
|
||||||
opacity = (opacity === undefined) ? 1 : opacity;
|
opacity = (opacity === undefined) ? 1 : opacity;
|
||||||
|
|
||||||
|
@ -31560,7 +31582,8 @@ var AnimationQueue = Backbone.Model.extend({
|
||||||
animations: null,
|
animations: null,
|
||||||
index: 0,
|
index: 0,
|
||||||
callback: null,
|
callback: null,
|
||||||
defer: false
|
defer: false,
|
||||||
|
promiseBased: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
|
@ -31570,6 +31593,13 @@ var AnimationQueue = Backbone.Model.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
thenFinish: function(promise) {
|
||||||
|
promise.then(_.bind(function() {
|
||||||
|
this.finish();
|
||||||
|
}, this));
|
||||||
|
this.set('promiseBased', true);
|
||||||
|
},
|
||||||
|
|
||||||
add: function(animation) {
|
add: function(animation) {
|
||||||
if (!animation instanceof Animation) {
|
if (!animation instanceof Animation) {
|
||||||
throw new Error("Need animation not something else");
|
throw new Error("Need animation not something else");
|
||||||
|
|
|
@ -842,12 +842,10 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
||||||
|
|
||||||
var chainStep = _.bind(function() {
|
var chainStep = _.bind(function() {
|
||||||
var newCommit = makeOriginCommit();
|
var newCommit = makeOriginCommit();
|
||||||
var animation = this.animationFactory.genCommitBirthPromiseAnimation(
|
return this.animationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.origin.gitVisuals
|
this.origin.gitVisuals
|
||||||
);
|
);
|
||||||
animation.play();
|
|
||||||
return animation.getPromise();
|
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
var deferred = Q.defer();
|
var deferred = Q.defer();
|
||||||
|
@ -862,6 +860,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
||||||
return chainStep();
|
return chainStep();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.animationQueue.thenFinish(chain);
|
||||||
|
|
||||||
deferred.resolve();
|
deferred.resolve();
|
||||||
};
|
};
|
||||||
|
@ -1764,13 +1763,16 @@ GitEngine.prototype.dispatch = function(command, deferred) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var willStartAuto = this.animationQueue.get('defer') ||
|
||||||
|
this.animationQueue.get('promiseBased');
|
||||||
|
|
||||||
// only add the refresh if we didn't do manual animations
|
// only add the refresh if we didn't do manual animations
|
||||||
if (!this.animationQueue.get('animations').length && !this.animationQueue.get('defer')) {
|
if (!this.animationQueue.get('animations').length && !willStartAuto) {
|
||||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||||
}
|
}
|
||||||
|
|
||||||
// animation queue will call the callback when its done
|
// animation queue will call the callback when its done
|
||||||
if (!this.animationQueue.get('defer')) {
|
if (!willStartAuto) {
|
||||||
this.animationQueue.start();
|
this.animationQueue.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,13 +58,18 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co
|
||||||
AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) {
|
AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) {
|
||||||
var visNode = commit.get('visNode');
|
var visNode = commit.get('visNode');
|
||||||
var anPack = makeCommitBirthAnimation(gitVisuals, visNode);
|
var anPack = makeCommitBirthAnimation(gitVisuals, visNode);
|
||||||
console.log('my duration', anPack.duration);
|
|
||||||
return new PromiseAnimation({
|
return new PromiseAnimation({
|
||||||
closure: anPack.animation,
|
closure: anPack.animation,
|
||||||
duration: anPack.duration
|
duration: anPack.duration
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) {
|
||||||
|
var animation = this.genCommitBirthPromiseAnimation(commit, gitVisuals);
|
||||||
|
animation.play();
|
||||||
|
return animation.getPromise();
|
||||||
|
};
|
||||||
|
|
||||||
AnimationFactory.prototype.overrideOpacityDepth2 = function(attr, opacity) {
|
AnimationFactory.prototype.overrideOpacityDepth2 = function(attr, opacity) {
|
||||||
opacity = (opacity === undefined) ? 1 : opacity;
|
opacity = (opacity === undefined) ? 1 : opacity;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,8 @@ var AnimationQueue = Backbone.Model.extend({
|
||||||
animations: null,
|
animations: null,
|
||||||
index: 0,
|
index: 0,
|
||||||
callback: null,
|
callback: null,
|
||||||
defer: false
|
defer: false,
|
||||||
|
promiseBased: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
|
@ -39,6 +40,13 @@ var AnimationQueue = Backbone.Model.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
thenFinish: function(promise) {
|
||||||
|
promise.then(_.bind(function() {
|
||||||
|
this.finish();
|
||||||
|
}, this));
|
||||||
|
this.set('promiseBased', true);
|
||||||
|
},
|
||||||
|
|
||||||
add: function(animation) {
|
add: function(animation) {
|
||||||
if (!animation instanceof Animation) {
|
if (!animation instanceof Animation) {
|
||||||
throw new Error("Need animation not something else");
|
throw new Error("Need animation not something else");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue