带缩略图的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/

你能做一个简短的jsfiddle示例吗???

编辑

使用这个旋转函数,问题在于如果val_x>maxSlide它必须>=并且在val_X++之后,但尝试

function rotate() {
    thumbFirst = jQuery(".fps-pagination li:first-child");
    thumbContainer = jQuery(".fps-pagination");
    animationSpeed = 800;

    thumbFirst.clone().appendTo(jQuery(".fps-pagination"));
    jQuery(".slides_control div.fps-slide:eq(" + val_x + ")").animate({ "opacity": "0" }, { queue: false, duration: animationSpeed });
    val_x++;
    if (val_x >= max_slide) { val_x = 0 }
    jQuery(".slides_control div.fps-slide:eq(" + val_x + ")").animate({ "opacity": "1" }, { queue: false, duration: animationSpeed });
    console.log(jQuery(".slides_control div.fps-slide:eq(" + val_x + ")").length + "valor x " + val_x);
    thumbContainer.animate({ "top": "-137px" }, { queue: false, duration: animationSpeed, complete: function () { thumbFirst.remove(); thumbContainer.css({ "top": "0px" }) } });
}

最新更新