Javascript question

Forum
Last Post
Threads / Messages

SilverDragonTears

I am your Nemesis.
Premium Member
Joined
Jun 1, 2011
Messages
1,113
Points
36
Mysidian Dollar
51,802
Can anyone familiar with javascript tell me how to make this scroll horizontal instead of vertical?

Code:
        //##########################################################################//
	// Scrolling background Tutorial Code by http://www.kudoswebsolutions.com
        // Original Source code: http://youlove.us/
        // Modified and extended by Kudos Web Solutions
        // copyright 2009 kudoswebsolutions.com
        //##########################################################################//

$(function() {
	// Define the height of your two background images.
           //The image to scroll
	   var backgroundheight = 2000;
           //The image to overlay
	   var backgroundheight_two = 1000;
	// Create a random offset for both images' starting positions
        offset = Math.round(Math.floor(Math.random()* 2001));

 
	function scrollbackground() {
                //Ensure all bases are covered when defining the offset.
   		offset = (offset < 1) ? offset + (backgroundheight - 1) : offset - 1;
		// Put the background onto the required div and animate vertically
   		$('#container').css("background-position", "50% " + offset + "px");
   		// Enable the function to loop when it reaches the end of the image
   		setTimeout(function() {
			scrollbackground();
			}, 100
		);
   	}
	function scrollbackground2() {
                //Ensure all bases are covered when defining the offset.
   		offset = (offset < 1) ? offset + (backgroundheight - 1) : offset - 1;
		// Put the background onto the required div and animate vertically
   		$('#container2').css("background-position", "50% " + offset + "px");
   		// Enable the function to loop when it reaches the end of the image
   		setTimeout(function() {
			scrollbackground2();
			}, 100
		);
   	}

	// Initiate the scroll
	scrollbackground();
	scrollbackground2();

	// Use the offset defined earlier and apply it to the div.
   		$('#overlay').css("background-position", "50% " + offset2 + "px");
   		$('#overlay2').css("background-position", "50% " + offset2 + "px");
});
 
I'm almost sure you noticed this, especially as (judging from your site) you have more experience than me. However I'll post it anyways in case it got overlooked or something...

" offset = (offset < 1) ? offset + (backgroundheight - 1) : offset - 1;
// Put the background onto the required div and animate vertically
$('# "

Do you think changing the "vertically" on both background things to "horizontally" would fix that? I'm sorry if you already tried this.. or if maybe it won't do anything at all to edit it.. just a thought/suggestion.

(I can't make codes, but /sometimes/ I can edit /little/ things if I can figure out what it does and how to move it. Though its a slow process ...)
 
That part is just a comment so changing the words won't fix it :/ Thanks for trying though :Q:
 
OH! No wonder those didn't help ^^;;
I misunderstood and thought you wanted a horizontal scrollbar.. *facepalms*
Sorry -,-

It looks awesome silver, kind of mysterious.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,280
Messages
33,132
Members
1,603
Latest member
Monako
BETA

Latest Threads

Top