riptide
06-11-2012, 10:50 PM
I really didn't want to make a thread but I couldn't find the answer else where. I'm using a script for a scrolling div.
scrollStep=4
timerLeft=""
timerRight=""
function toLeft(id){
document.getElementById(id).scrollLeft=0
}
function scrollDivLeft(id){
clearTimeout(timerRight)
document.getElementById(id).scrollLeft+=scrollStep
timerRight=setTimeout("scrollDivLeft('"+id+"')",10)
}
function scrollDivRight(id){
clearTimeout(timerLeft)
document.getElementById(id).scrollLeft-=scrollStep
timerLeft=setTimeout("scrollDivRight('"+id+"')",10)
}
function toRight(id){
document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth
}
function stopMe(){
clearTimeout(timerRight)
clearTimeout(timerLeft)
This function is connected to a div named scroll which has other divs in it.
the script came from.
http://www.javascriptsource.com/miscellaneous/scroll-div-horizontal.html#null
the CSS is
#scroller {
width:1000px;
1000px works but I wanted to change it to auto because the divs in the scroller may not take up that much space. And I don't want to be left with 500 or more px of space to the right of the content.
but the script doesn't work with width:auto. It does with width:100%
I was thinking that scrollWidth was not the right property. I can't prove either way right now.
Nothing from the scroller to the divs inside of it have any display property. Setting scroller with overflow to visible doesn't do anything either. I'm confused; I don't know if I need to edit the CSS or the JavaScript or both.
scrollStep=4
timerLeft=""
timerRight=""
function toLeft(id){
document.getElementById(id).scrollLeft=0
}
function scrollDivLeft(id){
clearTimeout(timerRight)
document.getElementById(id).scrollLeft+=scrollStep
timerRight=setTimeout("scrollDivLeft('"+id+"')",10)
}
function scrollDivRight(id){
clearTimeout(timerLeft)
document.getElementById(id).scrollLeft-=scrollStep
timerLeft=setTimeout("scrollDivRight('"+id+"')",10)
}
function toRight(id){
document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth
}
function stopMe(){
clearTimeout(timerRight)
clearTimeout(timerLeft)
This function is connected to a div named scroll which has other divs in it.
the script came from.
http://www.javascriptsource.com/miscellaneous/scroll-div-horizontal.html#null
the CSS is
#scroller {
width:1000px;
1000px works but I wanted to change it to auto because the divs in the scroller may not take up that much space. And I don't want to be left with 500 or more px of space to the right of the content.
but the script doesn't work with width:auto. It does with width:100%
I was thinking that scrollWidth was not the right property. I can't prove either way right now.
Nothing from the scroller to the divs inside of it have any display property. Setting scroller with overflow to visible doesn't do anything either. I'm confused; I don't know if I need to edit the CSS or the JavaScript or both.