前の関数を実行した後、次の関数を実行して連鎖反応を起こそうとしています。コードは次のようになります。
var med = {
imgLoadTime : 2000,
easingEffect : 'easeOutQuart',
scrollEase : 'easeInOutQuad',
effectDuration : 1000,
currentPage : '',
runAnimations : function(){
if(this.currentPage == '#slide5'){
this.initAssets();
}
},
initAssets : function(){
$('#asset-1').animate(
{left : '50%'},
{
duration: this.effectDuration,
easing: this.easingEffect,
complete: this.assetTwo
});
},
assetTwo : function(){
console.log('two');
debugger;
$('#asset-2').animate(
{left : '50%'},
{
duration: this.effectDuration,
easing: this.easingEffect,
complete: this.assetThree
});
},
assetThree : function(){
console.log('three');
$('#asset-3').animate(
{left : '50%'},
{
duration: this.effectDuration,
easing: this.easingEffect,
complete: console.log('weszlo')
});
}
};
これが私のオブジェクトの外観です。次に、関数 runAnimations をオブジェクトのプロパティとして実行します。このチェーンでは、assetTwo 関数のみが実行され、それ以上 (assetThree) が実行されないのは奇妙なことです。なんでそうなの?