2010-03-14 85 views
4

我已經使用「FeatureList」Jquery插件來創建我自己的內容滑塊。動畫幫助

該腳本可以在這裏找到:http://pastebin.com/7iyE5ADu

這裏是一個例證的圖像顯示什麼,我triyng實現:http://i41.tinypic.com/6jkeq1.jpg

其實滑塊添加一個「電流」類的項目(在例如正方形1,2和3)以及每個拇指在主區域中顯示內容。

在示例中,間隔2秒,腳本從1切換到2,從2切換到3等等。

我想製作一個連續的拇指動畫,任何人都可以幫助我?

+0

你見到我的更新的代碼!它支持多個項目! ;-) – 2010-03-18 12:26:40

回答

2
$(function() { 
    //go trought each LI 
    $('#tabs > li').each(function(i) { 
     // and Add incremental ID to each one... 
     $(this).attr('id', i + 1); 
    }); 
    //set interval... and call function 
    setInterval('swapImages()', 2000); 
}); 
function swapImages() { 
    var images = ['junku','codepoet','rappensuncle','nuomi','jam343','kk','ccgd','xdjio']; 
    //count all LI's 
    var total_lis = $('#tabs > li').size(); 
    // get the current LI ID based on where .current class... 
    var start_pos = parseInt($('#tabs li a.current').parent().attr('id')); 
    //remove the .current class for this LI... 
    $('li#' + start_pos).children().attr('class', ''); 
    //calculate next LI ID... 
    var next_pos = (start_pos < total_lis) ? start_pos + 1: 1; 
    //add .current class to the new LI 
    $('li#' + next_pos).children().attr('class', 'current'); 
    // monitor the position of current LI, if 3th OR multiple of the total do the magix... 
    if ((start_pos == 3) || (start_pos % total_lis == 0) || (next_pos == total_lis)) { 
     $('li#' + next_pos).prevAll().andSelf().attr('class', 'faded').fadeOut(200); 
     $('li#' + next_pos).nextAll('.faded').andSelf().attr('class', '').fadeIn(200); 
    } 
    //Append some stuff recursive... 
$('#output li').fadeOut(200,function() { 
    $(this).html('<img src="http://l.yimg.com/g/images/home_photo_' + images[next_pos] + '.jpg" />' + '<a href="#">See project details</a>').fadeIn(200); 
}); 
} 
+0

謝謝,但我的主要問題是,我想有超過3個元素滑動。在你的例子中想象下面的「應用程序」還有其他3個選項卡。 我希望讓他們從頭到尾滾動。 – Pennywise83 2010-03-15 04:26:58

+0

查看更新版本! ;-) – 2010-03-15 15:23:43

+0

獲取列表中的當前項目是一個很好的實現。 $('tabs li a.current') – Raja 2010-03-19 18:11:31