我已经定义了一个函数来为顶部的7个div动画。我试图用stop(true,false)函数来停止所有的元素。并通过再次调用该函数重新启动动画。请参阅下面的代码。问题是在我调用重新启动动画的函数后,动画变得非常慢。它会减速几秒钟,然后再次变为正常速度。有谁知道原因。请帮忙!!!由于jQuery动画在呼叫停止并重新启动后减速
我的代码是在下方附上
autoAnimate(5000);
$('#scroller_container').mouseenter(function(){
$('#scroller .galleryThumb').stop(true, false);
});
$('#scroller_container').mouseleave(function(){
autoAnimate(5000);
});
function autoAnimate(speed) {
$('#scroller .galleryThumb:eq(0)')
.animate({'top':'-122px'},speed,'linear',function(){
if(!autoFlag) {
index = $('#scroller .galleryThumb:last').attr('id');
index = index.substr(5, index.length);
index = parseInt(index);
index = index + 1;
autoFlag = true;
}
if(index == numberOfAds) { index = 0; }
$('#scroller .galleryThumb:eq(0)').remove();
$('#scroller').append(adUnitContainer[index]);
$('#scroller .galleryThumb:eq(6)').css('top','732px');
index++;
autoAnimate(speed);
});
$('#scroller .galleryThumb:eq(1)').animate({'top':'0px'},speed,'linear');
$('#scroller .galleryThumb:eq(2)').animate({'top':'122px'},speed,'linear');
$('#scroller .galleryThumb:eq(3)').animate({'top':'244px'},speed,'linear');
$('#scroller .galleryThumb:eq(4)').animate({'top':'366px'},speed,'linear');
$('#scroller .galleryThumb:eq(5)').animate({'top':'488px'},speed,'linear');
$('#scroller .galleryThumb:eq(6)').animate({'top':'610px'},speed,'linear');
}
它可能有助于在jsfiddle.net重新创建它,并在此处链接到它,以便其他人可以看到您的问题正在实施。 – JasCav