2012-05-10 29 views
1

我想讓屏幕底部的div移動到頂部,從不透明度0開始,在中間有不透明度1,並在頂部再次變爲0。一切都必須以3秒延遲開始。。帶有多重動畫的動畫隊列

 $("#circle") 
       .css({'display':'block'}) 
       .css({'opacity': '0'}) 
       .css({'top':$(window).height()}) 
       .delay(3000) 
       .animate({'opacity':1},{duration:1000},"linear") 
       .animate({'top':$(window).height()/2},{duration:1000, queue:false},"linear")     
       .animate({'opacity':0},{duration:1000},"linear") 
       .animate({'top':0},{duration:1000, queue:false},"linear") 

我也嘗試過'queue:false',但它仍然無法正常運行,而且這也不是線性的。 任何想法?

+0

問題是什麼?你有要求+代碼,但沒有問題 –

+0

爲什麼你的默認#circle CSS(顯示等)在CSS中設置? – atmd

回答

0

你應該更好的利用對象符號,如:

 $("#circle") 
       .css({ 
         'display':'block', 
         'opacity': '0', 
         'top':$(window).height() 
} 
) 
       .delay(3000) 
       .animate({ 
          'opacity':1 , 
          'top':$(window).height()/2 
         }, 
         {duration:1000},"linear") 
       .delay(1000) 
       .animate({ 
          'opacity':0, 
          'top':0 
         }, 
         {duration:1000},"linear"); 

你可以試試這個或嘗試設置使用$(this)選擇多條線路之間的延遲。

祝你好運,它總是有助於有一個jsfiddle鏈接。

+1

謝謝!所以拖延是問題所在。這並沒有產生線性動畫以爲這樣我就chaged到:.delay(3000) \t \t \t \t .animate({ '頂':$(窗口).height()/ 2, \t '不透明': '1' },2000, '線性',函數(){$ (本).animate({ '頂部':0, \t '不透明度': '0' },2000, '線性') ; \t}); – Daniel