Animation: Jquery on start?
i have this script in my page:
<script type="text/javascript">
var scrollSpeed = 70; // Speed in milliseconds
var step = 1; // How many pixels 开发者_开发技巧to move per step
var current = 0; // The current pixel row
var imageHeight = 2580; // Background image height
var headerHeight = 300; // How tall the header is.
//The pixel row where to start a new loop
var restartPosition = -(imageHeight - headerHeight);
function scrollBg() {
//Go to next pixel row.
current -= step;
//If at the end of the image, then go to the top.
if (current == restartPosition){
current = 0;
}
//Set the CSS of the header.
$('#wrapper1').css("background-position","0 "+current+"px");
}
//Calls the scrolling function repeatedly
var init = setInterval("scrollBg()", scrollSpeed);
</script>
the background is moving, how can i set an stoptimer, that the script runs after 10 seconds? i mean that the anmiation starts after 10 seconds.
Thanks Carsten
You can use the setTimeout()
function, like this: setTimeout('var init = setInterval("scrollBg()", scrollSpeed);', 10000);
.
The 10000 is the time in miliseconds it should wait before executing the expression, which is 10 seconds.
精彩评论