Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

settimeout and scroll problem!

Status
Not open for further replies.

VBmim

Programmer
Joined
Jun 25, 2001
Messages
361
Location
BE
I am trying to let my window scroll continuously while I am pointing a picture with my mouse (arrows, one up and one down).
What happens is if I point either one of the pictures, the window keeps scrolling till the end without scrolling, even if my mouse is at an other place by then...

here is my code:
Code:
//this function is called in the mouseover event of my UpArrow picture
function ScrollUpArrow ()
{
BoolScroll = true;
OutMouse = false;
while (BoolScroll == true)
{document.frames["HelmenIFrame"].window.scrollBy(0,1);
window.setTimeout("ScrollEnd()",10);
}
}

//this functino is called in the mouseover event of my DownArrow picture
function scrollDownArrow()
{
BoolScroll = true;
OutMouse = false;
while (BoolScroll == true)
{document.frames["HelmenIFrame"].window.scrollBy(0,-1);
window.setTimeout("ScrollEnd()",10);
}
}

//This function is called in the MouseOut event of both pictures
function MouseScrollEnd()
{OutMouse = true;}

function ScrollEnd()
{
if (OutMouse == true)
BoolScroll = false;
}

What the hell am I doing wrong!!

pleazzz help me!

greetz

Mim
 
To use and share BoolScroll and OutMouse values in more than one function declare them globally, outside the scope of any function --
Code:
  var BoolScroll = true;
  var OutMouse   = false;
Then all of your functions will use the same BoolScroll, OutMouse -- mouseover and mouseout will have better communication.
 
thanx for the reply!!

actually, I found what my problem was... (well, I think I have... :) ) While my script is in a while loop, it seems like it can catch no event at all, so I skipped the while-loop and did it like this:

Code:
function scrollDownArrow ()
{
OutMouse = false;
document.frames["HelmenIFrame"].window.scrollBy(0,2);
window.setTimeout("ScrollEndDown()",5);

}

function scrollUpArrow()
{
OutMouse = false;
document.frames["HelmenIFrame"].window.scrollBy(0,-2);
window.setTimeout("ScrollEndUp()",5);
}

function MouseScrollEnd()
{
OutMouse = true;
}

function ScrollEndUp()
{
if (OutMouse == false)
scrollUpArrow();
}

function ScrollEndDown()
{
if (OutMouse == false)
scrollDownArrow();
}

voila! I hope this helps others with a similar problem...

greetz

Mim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top