Well, you could do something like this (completely untested, sorry).

The hover events bind and unbind the mousemove to prevent resource drain.

$('#thisdiv').hover(startScroll,stopScroll);

function startScroll(e)
{
   var div = $(this).bind('mousemove',scrollThis);
   var o = div.offset();
   this.tempPosition = {
      left:o.left,
      top:o.top,
      right:o.left+div.width(),
      bottom:o.top+div.height(),
      scrollOffsetX:this.scrollWidth-this.clientWidth,
      scrollOffsetY:this.scrollHeight-this.clientHeight,
   };
}

function stopScroll(e)
{
   $(this).unbind('mousemove').removeAttr('tempPosition');
}

function scrollThis(e)
{
   // Use the e.clientX and e.clientY vs this.tempPosition 
   // to determine how much to move the scrollbars according 
   // to your tastes.
   this.scrollTop = setTop;
   this.scrollLeft = setLeft;
}


-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Dan
Sent: Wednesday, November 05, 2008 2:56 PM
To: jQuery (English)
Subject: [jQuery] Scrolling inside a div with mousemove


Hello,

I'm trying to move from MooTools over the jQuery as it seems to be a
much reliable and user friendly framework.

However I need to recreate something that I currently have MooTools
doing but am having trouble figuring out how it would work.

I'm trying to replicate the effect seen in the 'mousemove' example of
this MooTools page http://demos111.mootools.net/Scroller.

It doesn't need to scroll left and right but it's fine if it does, I'm
quite comfortable using JavaScript but just to warn you I'm very new
to jQuery :)

Thank you very much for any help.

Reply via email to