2011-10-11 95 views
1

我觉得这不是做事情的最有效的,也没有有效的方法:有没有比这更好的链接动画的方法?

line.stop(true, true).show('slide', {direction: whichway}, speed-150, function() { 
     title.stop(true, true).fadeIn(speed-200, function() { 
      sub.stop(true, true).show('slide', {direction: whichway}, speed-50, function() { 
       subtext.stop(true, true).show(); 
       paragraph.stop(true, true).slideDown(speed); 
      }); 
     }); 
    }); 

whichway /速度是动态的,但除此之外,它的所有的东西,必须是同步和排队。有没有更有效的方法来做到这一点?

+1

这可能是一个更好的问题http://codereview.stackexchange.com。 –

回答

0

使用大小写/切换语句。像这样:

function ani(step) { 
    switch(step) { 
     case 1: 
      line.stop(true, true).show('slide', {direction: whichway}, speed-150, function() {ani(2)}); 
      break; 
     case 2 
      title.stop(true, true).fadeIn(speed-200, function() { ani(3)}); 
      break; 


     ... 

     default: ani(1) 
    } 
} 
+0

是什么让这更快? –

+1

什么都没有。这是一个“更好的方式”,因为它不是嵌套的代码混乱。 –

相关问题