scrollBG-functie
Voor: WeBikeAmsterdam
by PhilQ
HTML
<div id="test"></div>
CSS
#test {
width: 500px;
height: 147px;
background: url("http://www.het-kofschip.nl/tekenlessen/img73.gif") 0px 0px repeat-x #ffff00;
}
JavaScript
$(document).ready(function() {
function scrollBG(c,a) {
var t = a.length;
var o = a[c][0];
var s = a[c][1];
var yb = a[c][2];
var ye = a[c][3];
$(o).animate({
'background-position-x': yb
}, s, 'linear', function() {
$(o).css({'background-position-x': ye});
if(c==(t-1)) {
c = 0;
} else {
c++;
}
scrollBG(c, a);
});
}
scrollBG(0,[["#test", 3000, "-183px", "-183px"],["#test", 5000, "-366px", "0px"]]);
});