我使用了“FeatureList”Jquery插件制作了自己的内容滑块。
可在此处找到该脚本:http://pastebin.com/7iyE5ADu
这是一个示例性图片,展示了我要实现的目标:http://i41.tinypic.com/6jkeq1.jpg
实际上,滑块会向项目添加“当前”类(在示例中为方块1,2和3),并且每个拇指都会在主区域中显示内容。
在示例中,间隔为2秒,脚本从1切换到2,从2切换到3,依此类推。
我想制作连续的拇指动画,任何人都可以帮助我吗?
答案 0 :(得分: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);
});
}