Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var scrollSpeed = 70; // Speed in milliseconds
- var step = 1; // How many pixels to move per step
- var current = 0; // The current pixel row
- var imageWidth = 9999; // Background image height
- var headerHeight = 1000; // How tall the header is.
- //The pixel row where to start a new loop
- var restartPosition = -(imageWidth - 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.
- $('#clouds').css("background-position","0 "+current+"px");
- }
- //Calls the scrolling function repeatedly
- var init = setInterval("scrollBg()", scrollSpeed);
Add Comment
Please, Sign In to add comment