Guest User

Untitled

a guest
Jun 25th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var scrollSpeed = 70;       // Speed in milliseconds
  2. var step = 1;               // How many pixels to move per step
  3. var current = 0;            // The current pixel row
  4. var imageWidth = 9999;     // Background image height
  5. var headerHeight = 1000;     // How tall the header is.
  6.  
  7. //The pixel row where to start a new loop
  8. var restartPosition = -(imageWidth - headerHeight);
  9.  
  10. function scrollBg(){
  11.    
  12.     //Go to next pixel row.
  13.     current -= step;
  14.    
  15.     //If at the end of the image, then go to the top.
  16.     if (current == restartPosition){
  17.         current = 0;
  18.     }
  19.    
  20.     //Set the CSS of the header.
  21.     $('#clouds').css("background-position","0 "+current+"px");
  22.    
  23.    
  24. }
  25.  
  26. //Calls the scrolling function repeatedly
  27. var init = setInterval("scrollBg()", scrollSpeed);
Add Comment
Please, Sign In to add comment