这是代码:
var stripeAnimation = function() {
var streetDivWidth = $('.street_name').width();
var streetFull = $('.street_name .street_name_text');
for(var i=0; i<streetFull.length; i++) {
var item = $(streetFull[i]);
var widthFull = item.width();
var remainder = widthFull - streetDivWidth;
var animationSpeed = widthFull * 5;
var summary = streetDivWidth - widthFull;
if(summary < 0) {
item.children('.gradient_span').addClass('gradient');
infinite();
setTimeout(infinite, 1000);
}
}
function infinite() {
item.animate({
marginLeft: '-' + remainder + 'px'
}, animationSpeed).animate({
marginLeft: 0
}, widthFull).delay(1000);
}
}
$(document).ready(function() {
stripeAnimation();
});
看起来它应该在 1000 毫秒的延迟内一遍又一遍地循环动画 - “setTimeout(infinite,1000);”。但事实并非如此。请帮忙!