0
我正在爲網頁製作一個自動動畫背景搖擺,而且我不知道如何解決當背景在最後回到原點。Swing效果jQuery動畫背景
這是我從其他網站做的代碼:
function scrollbackground() {
// decrease the offset by 1, or if its less than 1 increase it by the background height minus 1
// offset = (offset < 1) ? offset + (backgroundheight - 1) : offset - 1;
offset = offset - 1;
// apply the background position
$('body').css("background-position", "50% " + offset + "px");
// call self to continue animation
setTimeout(function() {
scrollbackground();
}, 1000
);
}
這都非常好,在一個方向移動。我要的是當背景到達一個特定的偏移,「重新長出」 0
謝謝!它工作正常! – JNestudi 2011-06-17 06:25:29