2011-04-08 45 views
0

只是想知道有沒有人知道一種讓葉子落在風中的方法?我已經看到它在這裏完成:http://www.webkit.org/blog-files/leaves/index.html但這只是WebKit。jQuery動畫從頭開始下降的葉子

到目前爲止我的代碼是非常基本的東西動畫:

function runParticles() { 
        $('.theme-bg').prepend('<div class="particles" style="position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; min-height: 100%; background-image: url(images/particle1.png); z-index: 1; background-repeat: no-repeat; background-position: 0px 0px;"></div>'); 

        var randParXa = Math.floor(Math.random() * $('.theme-bg').width()); 
        var randParXb = Math.floor(Math.random() * $('.theme-bg').width()); 
        var randParY = $('.theme-bg').height(); 
        var randParSpd = Math.floor(Math.random() * (2500 - 1550) + 1550); 

        $('.particles').css({'background-position':randParXa+'px 0px'}); 
        $('.particles').animate({ 
         'background-position':randParXb+'px '+randParY+'px', 
         'opacity':0.0 
        }, randParSpd, function() { 
         $(this).remove(); 
         runParticles(); 
        }); 
       } 
       runParticles(); 

幫助將不勝感激。

Urgh,需要更多的信息(我猜,由於投票關閉......?)
所以,我想一個元素<div>從瀏覽器和「浮動」的頂部落在從左至右它落下......像一片樹葉或一片羽毛。

目前,我的動畫只是直線前進。

再次歡呼!

+1

我還要指出的是,背景位置動畫提供://www.protofunc.com/scripts/jquery/backgroundPosition/jquery.backgroundPosition.js – 2011-04-08 19:13:19

回答