2011-10-11 105 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

什麼都沒有。這是一個「更好的方式」,因爲它不是嵌套的代碼混亂。 –

相關問題