0

所以我所拥有的是一个大图像,当有人在页面上时,我试图连续制作动画

我现在要做的是:

$('.photobanner').animate({ 
    backgroundPosition:"(-10000px 0px)" 
}, 80000, 'linear');

这有效..但它似乎结束并停止..我可以无限做同样的动画吗?

现在它工作了----

var counter=0;
function moveBG(y)
{
    counter=counter-1000;
    $('.photobanner').animate({ backgroundPosition:"("+counter+"px 0px)" }, 8000, 'linear',moveBG);
}

我定义了一个计数器,它将递增到无穷大并使用了这个函数。

4

1 回答 1

3

你总是可以做这样的事情:

function moveBG()
{
    $('.photobanner').css({ backgroundPosition:"(0px 0px)"});
    $('.photobanner').animate({ backgroundPosition:"(-1000px 0px)" }, 8000, 'linear',moveBG);
}

使函数的回调重做函数。不过,它必须是一个无缝的图像。

于 2012-10-23T21:11:19.650 回答