PDA

View Full Version : Left-Right scrolling window script



Dan71121
01-19-2006, 02:20 AM
Hello All - I would like to edit this script so that it only scrolls from left to right once and then stops. Currently is scrolls, gets to the end, then returns back to the beginning and scroll again. Below is the script. Can anyone lend some assistance? Thanks, Dan

<script language="JavaScript1.2">

var speed=3
var currentpos=0,alt=1,curpos1=0,curpos2=-1
function initialize(){
startit()
}

function iecompattest(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body
}

function scrollwindow(){
if (document.all)
temp=iecompattest().scrollLeft
else
temp=window.pageXOffset
if (alt==0)
alt=1
else
alt=0
if (alt==0)
curpos1=temp
else
curpos2=temp
if (curpos1!=curpos2){
if (document.all)
currentpos=iecompattest().scrollLeft+speed
else
currentpos=window.pageXOffset+speed
window.scroll(currentpos,0)
}
else{
currentpos=0
window.scroll(currentpos,0)
}
}
function startit(){
setInterval("scrollwindow()",10)
}
window.onload=initialize
</script>

jscheuer1
01-19-2006, 06:19 AM
Not even the demo of this script seems to work very well for me. Do you have a demo page of your own that does what you want except for stopping when you want it to?

.

Dan71121
01-19-2006, 10:22 AM
Thanks for your help! Below is the URL.

http://www.loftusphoto.com/gallery.php

Once you are on this page, select the Top, Right thumbnail (the one with the groom dipping the bride). This is the gallery I'm using as a test and it is working fine except it is repeating and I only want it to scroll across once.

Thanks again for your help! - Dan

jscheuer1
01-19-2006, 09:19 PM
Well, that certainly looks much nicer! OK, you have two choices. #1 is what I think you say you want, is to stop at the end of one scroll. To do that , change this line:


setInterval("scrollwindow()",10)

to:


scrollInt=setInterval("scrollwindow()",10)

and these lines:


else{
currentpos=0
window.scroll(currentpos,0)
}

to:


else
clearInterval(scrollInt)

The other possibility would be to have it stop and return to the beginning. For that, the first line change is still used but the second change needs to end up looking like so:


else{
clearInterval(scrollInt)
currentpos=0
window.scroll(currentpos,0)
}

Dan71121
01-24-2006, 11:37 AM
Thanks, John...worked like a charm!

Just read the standards notice so here is the info to the script in case anyone is interested:

Left-Right scrolling window script
http://www.dynamicdrive.com/dynamicindex8/leftscroll.htm