Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    817
    Thanks
    43
    Thanked 6 Times in 5 Posts

    scroll script goes too fast

    This script has been around a while (I know it's old) but it works in IE when you mouseover an image...you can make text scroll up or down.

    The problem is it goes pretty fast, even if you use the lowest speed (1). Is there a way to slow it down. Or a better script lying around anywhere?

    Code:
    function verScroll(dir, spd, loop) {
    loop = true;
    direction = "up";
    speed = 10;
    scrolltimer = null;
    if (document.layers) {
    var page = eval(document.contentLayer);
    }
    else {
    if (document.getElementById) {
    var page= eval("document.getElementById('contentLayer').style");
    }
    else {
    if (document.all) {
    var page = eval(document.all.contentLayer.style);
          }
       }
    }
    direction = dir;
    speed = parseInt(spd);
    var y_pos = parseInt(page.top);
    if (loop == true) {
    if (direction == "dn") {
    page.top = (y_pos - (speed));
    } else {
    if (direction == "up" && y_pos < 10) {
    page.top = (y_pos + (speed));
    } else {
    if (direction == "top") {
    page.top = 10;
          }
       }
    }
    scrolltimer = setTimeout("verScroll(direction,speed)", 1);
       }
    }
    function stopScroll() {
    loop = false;
    clearTimeout(scrolltimer);
    }
    
    EXAMPLE:
    <a href="#" onmouseover="verScroll('up','1','true')" onmouseout="stopScroll()" style="text-decoration: none">
    <span class="1">&nbsp;&nbsp;◄◄&nbsp;&nbsp;</span></a>
    The difference between genius and stupidity is that genius has its limits. (Albert Einstein)

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    620
    Thanks
    1
    Thanked 20 Times in 20 Posts
    The person who wrote it probably believed that the timer is in seconds and expected the "1" in the following line to indicate "1 second."
    Code:
    scrolltimer = setTimeout("verScroll(direction,speed)", 1);
    It's actually in milliseconds. Change it like this to slow down to 1 second, and then lower the "1000" to get the effect that you want:
    Code:
    scrolltimer = setTimeout("verScroll(direction,speed)", 1000);

  • #3
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    817
    Thanks
    43
    Thanked 6 Times in 5 Posts
    Thanks! You are correct!
    The difference between genius and stupidity is that genius has its limits. (Albert Einstein)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •