Помогите с анимацией - PullRequest
4 голосов
/ 14 марта 2010

Я использовал плагин JQuery FeatureList, чтобы создать свой собственный слайдер контента.

Сценарий можно найти здесь: http://pastebin.com/7iyE5ADu

Вот примерное изображение, показывающее, чего я хочу достичь: http://i41.tinypic.com/6jkeq1.jpg

На самом деле ползунок добавляет «текущий» класс к элементу (в примере квадраты 1,2 и 3) и для каждого большого пальца показывает содержимое в основной области.

В примере с интервалом в 2 секунды сценарий переключается с 1 на 2, с 2 на 3 и т. Д.

Я бы хотел сделать непрерывную анимацию больших пальцев, кто-нибудь может мне помочь?

1 Ответ

2 голосов
/ 14 марта 2010
$(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);
});
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...