Click to See Complete Forum and Search --> : onscroll event


yaron
10-01-2003, 06:33 AM
Hello,
I'm using the onscroll event to sync up multiple frames.
what I need is to know whether the horizontal scroll was causing onscroll event or the vertical scroll.
How can I know?

Gollum
10-01-2003, 08:58 AM
you can store the scrollLeft and scrollTop values somewhere and see which one changes in your onscroll event.

Note: this is rather browser dependant.

yaron
10-01-2003, 09:51 AM
Where do I need to store it?
can you give a simple example please. my js isn't my strong side...

Gollum
10-02-2003, 02:08 AM
Just store them at 'global' scope...

var xScroll = 0;
var yScroll = 0;
function myOnscroll()
{
if ( xScroll != document.body.scrollLeft )
{
// horizontal scroll
}
else if ( yScroll != document.body.scrollTop )
{
// vertical scroll
}
xScroll = document.body.scrollLeft;
yScroll = document.body.scrollTop;

}