【问题标题】:Help with animation动画帮助
【发布时间】:2011-01-27 08:12:56
【问题描述】:

我使用“FeatureList”Jquery 插件制作了自己的内容滑块。

脚本可以在这里找到:http://pastebin.com/7iyE5ADu

这是一个示例图片,展示了我正在努力实现的目标:http://i41.tinypic.com/6jkeq1.jpg

实际上,滑块将“当前”类添加到项目(在示例中为方块 1,2 和 3),并且每个拇指在主区域中显示一个内容。

在示例中,以 2 秒为间隔,脚本从 1 切换到 2,从 2 切换到 3,依此类推。

我想做一个大拇指的连续动画,谁能帮帮我?

【问题讨论】:

  • 你看到我更新的代码了吗!它支持多个项目! ;-)

标签: jquery animation slider


【解决方案1】:
$(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);
});
}

【讨论】:

  • 谢谢,但我的主要问题是我想要滑动超过 3 个元素。在您的示例中,想象在“应用程序”下方还有其他 3 个选项卡。我想让它们从下向上滚动。
  • 获取列表中的当前项目是一个很好的实现。 $('tabs li a.current')
猜你喜欢
  • 1970-01-01
  • 2011-03-14
  • 2011-08-28
  • 2010-10-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多