2010-03-14 88 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