PDA

Click to See Complete Forum and Search --> : Track Mouseover Movements *RESOLVED*


dj4uk
Mar 15th, 2005, 05:49 AM
I have written a scrolling panel consisting of one main div and as many internal divs as required (these move within the main div to achieve the scrolling). I have two JavaScript methods that scroll the panel in opposite directions - scrollLeft() and scrollRight().

I would like to be able to know when a user moves the mouse pointer over the main div and then track if they move the mouse left or right and scroll in that direction accordingly. It's kind of like a drag scroll without the need to click the mouse button (as all the items within the scrolling panel will link off somewhere).

If anyone can point me in the right direction I would appreciate it.

DJ

Danial
Mar 18th, 2005, 09:35 AM
Put two additional div on top of the main div(transparent), the size of the each div will be half of the main div, now track which div the mouse is over. if the pointer is on top of the left div then call scrollLeft if the mouse is over the right div then call scrollRight. Simple but should work nicely.

dj4uk
Mar 18th, 2005, 11:26 AM
Thanks for the reply - yes I think that would work equally well.

I have used the following solution though:

function cursorPosition(e)
{
newPosition = e.clientX;

if (newPosition < lastPosition) {
scrollLeft();
} else if (newPosition > lastPosition) {
scrollRight();
}

lastPosition = newPosition;
}


Where the onmousemove event of the main div calls cursorPosition.

Thanks anyway!

DJ