我试图通过在执行前一个函数后执行下一个函数来产生连锁反应。代码如下所示:
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)。为什么这样?