带缩略图的 jQuery 无限轮播
我正在制作一个滑块,我的缩略图出现了一些问题,它们的动画速度比主图像的淡入淡出速度更快,(在几个拇指动画之后,它们与主幻灯片的动画异步......他们需要在同一时刻)它们具有相同的速度,所以我不明白为什么会产生此错误...
jQuery(document).ready(function(){
speed = 8000;
max_slide = jQuery(".slides_control div.fps-slide").size();
val_x = 0;
run = setInterval('rotate()', speed);
jQuery("#slider").hover(
function () { clearInterval(run); },
function () { run = setInterval('rotate()', speed); }
);
});
function rotate() {
thumbFirst = jQuery(".fps-pagination li:first-child");
thumbContainer = jQuery(".fps-pagination");
animationSpeed = 800;
if (val_x > max_slide) { val_x = 0 }
thumbFirst.clone().appendTo(jQuery(".fps-pagination"));
jQuery(".slides_control div.fps-slide:eq("+val_x+")").animate({"opacity":"0"}, { queue: false, duration: animationSpeed });
val_x++;
jQuery(".slides_control div.fps-slide:eq("+val_x+")").animate({"opacity":"1"}, { queue: false, duration: animationSpeed });
thumbContainer.animate(
{"top":"-137px"},
{queue:false, duration: animationSpeed,
complete: function() {
thumbFirst.remove();
thumbContainer.css({"top": "0px"})
}
});
}
jsFiddle : http://jsfiddle.net/AY3y2/1/ (在此环境中效果不佳) 实时代码: http://webserver.lewebsimple.ca/~tempcode/
I'm making a slider and I got some problem with my thumbnail, they animate faster then the fade of the main image, (After a couple of thumb animate, they are asyncrone with the animate of the main slide... they need to be at the same moment) they have the same speed, so I don't understand why that producing this error...
jQuery(document).ready(function(){
speed = 8000;
max_slide = jQuery(".slides_control div.fps-slide").size();
val_x = 0;
run = setInterval('rotate()', speed);
jQuery("#slider").hover(
function () { clearInterval(run); },
function () { run = setInterval('rotate()', speed); }
);
});
function rotate() {
thumbFirst = jQuery(".fps-pagination li:first-child");
thumbContainer = jQuery(".fps-pagination");
animationSpeed = 800;
if (val_x > max_slide) { val_x = 0 }
thumbFirst.clone().appendTo(jQuery(".fps-pagination"));
jQuery(".slides_control div.fps-slide:eq("+val_x+")").animate({"opacity":"0"}, { queue: false, duration: animationSpeed });
val_x++;
jQuery(".slides_control div.fps-slide:eq("+val_x+")").animate({"opacity":"1"}, { queue: false, duration: animationSpeed });
thumbContainer.animate(
{"top":"-137px"},
{queue:false, duration: animationSpeed,
complete: function() {
thumbFirst.remove();
thumbContainer.css({"top": "0px"})
}
});
}
jsFiddle : http://jsfiddle.net/AY3y2/1/ (Not working well in this environement)
Live code: http://webserver.lewebsimple.ca/~tempcode/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你能做一个简短的 jsfiddle 例子吗???
编辑
使用此旋转函数,您的问题在于 if val_x >最大滑动
它必须是 >= 并且在 val_X ++ 之后,但是尝试一下
can you make a short jsfiddle example???
Edit
use this rotate function, your problem was in if val_x > maxSlide
it must be >= and after the val_X ++, but try it