我已经定义了一个函数来动画 7 个 div 到顶部。我尝试使用 stop(true, false) 函数来停止所有元素。并通过再次调用该函数重新启动动画。请看下面的代码。问题是我调用函数重新启动动画后动画变得非常慢。它慢了几秒钟,然后又恢复了正常速度。有谁知道原因。请帮忙!!!谢谢
我的代码附在下面
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');
}