October 31, 2011

jSCROLLPANE: Horizontal Scrolling with Scroll Wheel

I came across the issue that the track ball scrolling didn’t work with jScrollPane. I found the fix in a google group that the creator of jScrollPane Kelvin Luck gave himself ( http://tinyurl.com/3ku9d9b ). Here is the solution:

  1.  var element = $('.scroll-pane').jScrollPane();
  2.  var api = element.data('jsp');
  3.  element.bind(
  4.       'mousewheel',
  5.       function (event, delta, deltaX, deltaY)
  6.       {
  7.           api.scrollByX(delta * 30);
  8.           return false;
  9.       }
  10.  );

I made a couple additions like adding the actual scroll-pane class and the ( delta * 30 ) to speed up the scroll pace.