Search code examples
javascriptjqueryscrollbarjscrollpane

jScrollPane how do i remove the mousewheel functionalitie


Whenever my mouse enters jScrollPane and i use my mousewheel i want the scrollbar of the browser itself to scroll instead of the one on in jScrollPane.

So when i'm scrolling down in my browser with my mousewheel and i pass over the jScrollPane with my mouse it shouldn't stop scrolling down in the browser.

Why? I am using a horizontal scrollbar in my jScrollPane and i want my mousewheel for vertical scrolling only.

Hope this makes sense and isn't to vague.


Solution

  • Mhh.. it does not seem jScrollPane has something to enable/disable mousewheel, but you can find 2 solutions I think:

    1. Do not include the jquery mousewheel plugin (that is optional for jScrollPane)

    2. Unbind the "mousewheel" event of the container with jQuery AFTER having used the $(**yourcontainer**).jScrollPane(); like that :

      $(**yourcontainer**).unbind('mousewheel');
      

    Edit :

    Here is the pluggin code that bind the mousewheel event :

     $container.bind(
       'mousewheel',
       function (event, delta) {
         delta = delta || (event.wheelDelta ? event.wheelDelta / 120 : (event.detail) ? -event.detail/3 : 0);
         initDrag();
         ceaseAnimation();
         var d = dragPosition;
         positionDrag(dragPosition - delta * mouseWheelMultiplier);
         var dragOccured = d != dragPosition;
         return !dragOccured;
       }
     );
    

    And here the description of the plugin and its config :

     * @name jScrollPane
     * @type jQuery
     * @param Object        settings        hash with options, described below.
     *                                                              scrollbarWidth  -       The width of the generated scrollbar in pixels
     *                                                              scrollbarMargin -       The amount of space to leave on the side of the scrollbar in pixels
     *                                                              wheelSpeed              -       The speed the pane will scroll in response to the mouse wheel in pixels
     *                                                              showArrows              -       Whether to display arrows for the user to scroll with
     *                                                              arrowSize               -       The height of the arrow buttons if showArrows=true
     *                                                              animateTo               -       Whether to animate when calling scrollTo and scrollBy
     *                                                              dragMinHeight   -       The minimum height to allow the drag bar to be
     *                                                              dragMaxHeight   -       The maximum height to allow the drag bar to be
     *                                                              animateInterval -       The interval in milliseconds to update an animating scrollPane (default 100)
     *                                                              animateStep             -       The amount to divide the remaining scroll distance by when animating (default 3)
     *                                                              maintainPosition-       Whether you want the contents of the scroll pane to maintain it's position when you re-initialise it - so it doesn't scroll as you add more content (default true)
     *                                                              tabIndex                -       The tabindex for this jScrollPane to control when it is tabbed to when navigating via keyboard (default 0)
     *                                                              enableKeyboardNavigation - Whether to allow keyboard scrolling of this jScrollPane when it is focused (default true)
     *                                                              animateToInternalLinks - Whether the move to an internal link (e.g. when it's focused by tabbing or by a hash change in the URL) should be animated or instant (default false)
     *                                                              scrollbarOnLeft -       Display the scrollbar on the left side?  (needs stylesheet changes, see examples.html)
     *                                                              reinitialiseOnImageLoad - Whether the jScrollPane should automatically re-initialise itself when any contained images are loaded (default false)
     *                                                              topCapHeight    -       The height of the "cap" area between the top of the jScrollPane and the top of the track/ buttons
     *                                                              bottomCapHeight -       The height of the "cap" area between the bottom of the jScrollPane and the bottom of the track/ buttons
     *                                                              observeHash             -       Whether jScrollPane should attempt to automagically scroll to the correct place when an anchor inside the scrollpane is linked to (default true)
     * @return jQuery