tilfin / jquery-scrollview

Automatically exported from code.google.com/p/jquery-scrollview
0 stars 0 forks source link

Better mouseout handling #9

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
How to reproduce:
Make a page full of small DIVs. Make the page scrollable using scrollview. Open 
in Chrome. Grab the page to scroll, then vigorously move cursor right and left. 
You will notice that the cursor will be somewhat "elastic", and as soon at it 
moves to another div in the page, scrolling will stop.

Observed result: Scrolling stops if cursor "shaken" fast enough.
Expected/desired result: Scrolling remains as long as cursor inside the 
scrollable area.

Reason:
.mouseout(function(){ self.stopgrab() })

The mouseout even is fired whenever the mouse cursor leaves a container. If 
scrollview is applied to the whole page, yet the mouse leaves a container 
INSIDE that page, the mouseout event will be fired and scrolling will suddently 
stop. The user will have to grab the page again to continue scrolling. If the 
cursor is moved fast during scrolling, this unfortunate effect can happen.

Solution (proposed and tested):
Replace the line
.mouseout(function(){ self.stopgrab() })
by
.mouseleave(function(){ self.stopgrab() })

The mouseleave event is implemented by jquery. It will only fire if the mouse 
leaves the current container, in this case the scrollable area. As opposed to 
mouseout, it will not fire if the mouse leaves any child elements inside the 
container.

Original issue reported on code.google.com by rolf.der...@gmail.com on 9 Jul 2011 at 10:36

GoogleCodeExporter commented 9 years ago
Thanks a lot man. You save me a lot of time with this fix =) +1

Original comment by odeskd...@gmail.com on 13 Dec 2011 at 2:37

GoogleCodeExporter commented 9 years ago
You're welcome :)

Original comment by rolf.der...@gmail.com on 14 Dec 2011 at 8:48