Jquery .animate()忽略动画持续时间

时间:2013-12-03 11:18:31

标签: jquery

fade_time变量设置为3000,但动画比这快得多。我也试过传入3000而不是唱变量,但这并没有帮助。这是我的代码,欢迎任何想法。

$images.filter(':eq(' + current_pic_idx + ')').css({
    zIndex: 50
});
$images.filter(':eq(' + nextPic + ')').css({
    zIndex: 100,
    opacity: 0
}).animate({
    opacity: 100
}, {
    duration: fade_time,
    complete: function () {
        $images.filter(':eq(' + current_pic_idx + ')').css({
            zIndex: 0
        });

        current_pic_idx = current_pic_idx + 1;
        if (current_pic_idx == $images.size()) {
            current_pic_idx = 0;
        }

        window.setTimeout(showNextImage, timer_delay);
    }
});

1 个答案:

答案 0 :(得分:0)

使用以下语法尝试:

.animate({
    opacity: 100
}, fade_time, function () {
        $images.filter(':eq(' + current_pic_idx + ')').css({
            zIndex: 0
        });

        current_pic_idx = current_pic_idx + 1;
        if (current_pic_idx == $images.size()) {
            current_pic_idx = 0;
        }
     window.setTimeout(showNextImage, timer_delay);
    });