Skip to content
Permalink
Browse files

fixes #13561, gotoPercent has no effect on fx.chain

  • Loading branch information...
nicknisi authored and dylans committed May 7, 2014
1 parent 4025957 commit 4120dbacf0b5738d09ae25a5379a25450937126b
Showing with 43 additions and 4 deletions.
  1. +7 −4 fx.js
  2. +36 −0 tests/fx.html
11 fx.js
@@ -107,17 +107,20 @@ define([
this.pause();
var offset = this.duration * percent;
this._current = null;
arrayUtil.some(this._animations, function(a){
if(a.duration <= offset){

arrayUtil.some(this._animations, function(a, index){
if(offset <= a.duration){
this._current = a;
this._index = index;
return true;
}
offset -= a.duration;
return false;
});
}, this);
if(this._current){
this._current.gotoPercent(offset / this._current.duration, andPlay);
this._current.gotoPercent(offset / this._current.duration);
}
if (andPlay) { this.play(); }
return this;
},
stop: function(/*boolean?*/ gotoEnd){
@@ -85,6 +85,41 @@
}
},
{
name: "gotoPercent Chain",
timeout: 2000,
runTest: function (t) {
var d = new doh.Deferred(),
node = dom.byId('baz'),
anims = [
baseFx.fadeOut({node:node}),
baseFx.fadeIn({node:node}),
fx.wipeOut({node:node}),
fx.wipeIn({node:node}),
fx.slideTo({node:node,top:200,left:300})
],
chain = fx.chain(anims),
len = anims.length,
percent = 0.34,
totalActive = len - Math.floor(percent * len),
numRun = 0;
array.forEach(anims, function (anim, index) {
aspect.before(anim, 'onEnd', function () {
numRun++;
});
});
aspect.after(chain, 'onEnd', function () {
doh.t(totalActive === numRun);
d.callback(true);
});
chain.gotoPercent(percent, true);
return d;
}
},
{
name: "combine",
timeout: 1500,
@@ -484,6 +519,7 @@
</div>

<p id="a1">p</p><p id="a2">p</p>
<div id="baz">baz</div>

</body>
</html>

0 comments on commit 4120dba

Please sign in to comment.
You can’t perform that action at this time.