diff --git a/build/bundle.js b/build/bundle.js index 4a823a23..75f49ffc 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -7895,12 +7895,10 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) { var chainStep = _.bind(function() { var newCommit = makeOriginCommit(); - var animation = this.animationFactory.genCommitBirthPromiseAnimation( + return this.animationFactory.playCommitBirthPromiseAnimation( newCommit, this.origin.gitVisuals ); - animation.play(); - return animation.getPromise(); }, this); var deferred = Q.defer(); @@ -7915,6 +7913,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) { return chainStep(); }); } + this.animationQueue.thenFinish(chain); deferred.resolve(); }; @@ -8817,13 +8816,16 @@ GitEngine.prototype.dispatch = function(command, deferred) { return; } + var willStartAuto = this.animationQueue.get('defer') || + this.animationQueue.get('promiseBased'); + // 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); } // animation queue will call the callback when its done - if (!this.animationQueue.get('defer')) { + if (!willStartAuto) { this.animationQueue.start(); } }; @@ -9203,13 +9205,18 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co 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.playCommitBirthPromiseAnimation = function(commit, gitVisuals) { + var animation = this.genCommitBirthPromiseAnimation(commit, gitVisuals); + animation.play(); + return animation.getPromise(); +}; + AnimationFactory.prototype.overrideOpacityDepth2 = function(attr, opacity) { opacity = (opacity === undefined) ? 1 : opacity; @@ -9453,7 +9460,8 @@ var AnimationQueue = Backbone.Model.extend({ animations: null, index: 0, callback: null, - defer: false + defer: false, + promiseBased: false, }, 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) { if (!animation instanceof Animation) { throw new Error("Need animation not something else"); @@ -23798,12 +23813,10 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) { var chainStep = _.bind(function() { var newCommit = makeOriginCommit(); - var animation = this.animationFactory.genCommitBirthPromiseAnimation( + return this.animationFactory.playCommitBirthPromiseAnimation( newCommit, this.origin.gitVisuals ); - animation.play(); - return animation.getPromise(); }, this); var deferred = Q.defer(); @@ -23818,6 +23831,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) { return chainStep(); }); } + this.animationQueue.thenFinish(chain); deferred.resolve(); }; @@ -24720,13 +24734,16 @@ GitEngine.prototype.dispatch = function(command, deferred) { return; } + var willStartAuto = this.animationQueue.get('defer') || + this.animationQueue.get('promiseBased'); + // 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); } // animation queue will call the callback when its done - if (!this.animationQueue.get('defer')) { + if (!willStartAuto) { this.animationQueue.start(); } }; @@ -31309,13 +31326,18 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co 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.playCommitBirthPromiseAnimation = function(commit, gitVisuals) { + var animation = this.genCommitBirthPromiseAnimation(commit, gitVisuals); + animation.play(); + return animation.getPromise(); +}; + AnimationFactory.prototype.overrideOpacityDepth2 = function(attr, opacity) { opacity = (opacity === undefined) ? 1 : opacity; @@ -31560,7 +31582,8 @@ var AnimationQueue = Backbone.Model.extend({ animations: null, index: 0, callback: null, - defer: false + defer: false, + promiseBased: false, }, 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) { if (!animation instanceof Animation) { throw new Error("Need animation not something else"); diff --git a/src/js/git/index.js b/src/js/git/index.js index 35836829..6915b39e 100644 --- a/src/js/git/index.js +++ b/src/js/git/index.js @@ -842,12 +842,10 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) { var chainStep = _.bind(function() { var newCommit = makeOriginCommit(); - var animation = this.animationFactory.genCommitBirthPromiseAnimation( + return this.animationFactory.playCommitBirthPromiseAnimation( newCommit, this.origin.gitVisuals ); - animation.play(); - return animation.getPromise(); }, this); var deferred = Q.defer(); @@ -862,6 +860,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) { return chainStep(); }); } + this.animationQueue.thenFinish(chain); deferred.resolve(); }; @@ -1764,13 +1763,16 @@ GitEngine.prototype.dispatch = function(command, deferred) { return; } + var willStartAuto = this.animationQueue.get('defer') || + this.animationQueue.get('promiseBased'); + // 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); } // animation queue will call the callback when its done - if (!this.animationQueue.get('defer')) { + if (!willStartAuto) { this.animationQueue.start(); } }; diff --git a/src/js/visuals/animation/animationFactory.js b/src/js/visuals/animation/animationFactory.js index e77aa53e..4eb894d6 100644 --- a/src/js/visuals/animation/animationFactory.js +++ b/src/js/visuals/animation/animationFactory.js @@ -58,13 +58,18 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co 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.playCommitBirthPromiseAnimation = function(commit, gitVisuals) { + var animation = this.genCommitBirthPromiseAnimation(commit, gitVisuals); + animation.play(); + return animation.getPromise(); +}; + AnimationFactory.prototype.overrideOpacityDepth2 = function(attr, opacity) { opacity = (opacity === undefined) ? 1 : opacity; diff --git a/src/js/visuals/animation/index.js b/src/js/visuals/animation/index.js index c2ab5ff1..76bad8c2 100644 --- a/src/js/visuals/animation/index.js +++ b/src/js/visuals/animation/index.js @@ -29,7 +29,8 @@ var AnimationQueue = Backbone.Model.extend({ animations: null, index: 0, callback: null, - defer: false + defer: false, + promiseBased: false, }, 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) { if (!animation instanceof Animation) { throw new Error("Need animation not something else");