views:

83

answers:

1

Hi i'm using the jQuery mousewheel extension

and it uses the following bind

$('html').bind('mousewheel', function(event, delta) {
  window.scrollBy(-120 * delta, 0);
  return false;
}); 

The delta is determined by the mouse wheel movement and the page scrolls horizontally.

All is fine except when you move the cursor on an empty space where there is no text or image, generally no html element then the mousewheel movement is suddenly unresponsive. I'm positive this is because of how the bind is working.

I made an invisible 100% by 100% fixed pos div to test my theory and the scrolling would work perfectly. Though this seems like a hack to me, and i was wondering of the proper implementations of this code.

How can i make this function be called all over the browser page?

Thank you so much!

Update: David took the initiative to make a test page with his code here. Can anyone tell me if it works for you as it does for him? It doesn't work for me, that is i can only scroll the page horizontally only if my pointer is over the red rectangle.

+3  A: 

Did you try binding it to the document or window?

$(document).bind('mousewheel', function(event, delta) {
  window.scrollBy(-120 * delta, 0);
  return false;
}); 
David
ah, I just tried that with no luck. Still functions the same : ( is that unusual? Thanks though!!
Mohammad
I probably sound a bit noobish here, but is it possible to be inspired by the code itself and bind the function to when the mousewheel movement?link: http://github.com/brandonaaron/jquery-mousewheel/blob/master/jquery.mousewheel.js
Mohammad
Works fine here: http://jsbin.com/icodi
David
thanks for creating that page David. For me, both in Safari and Chrome I have to point the cursor on the red rectangle for the mousewheel to move the page. Which browser are you using?
Mohammad