2

每当我的鼠标进入 jScrollPane 并使用鼠标滚轮时,我希望浏览器本身的滚动条滚动而不是 jScrollPane 中的滚动条。

因此,当我用鼠标滚轮在浏览器中向下滚动并用鼠标越过 jScrollPane 时,它​​不应该停止在浏览器中向下滚动。

为什么?我在我的 jScrollPane 中使用水平滚动条,我希望我的鼠标滚轮仅用于垂直滚动。

希望这是有道理的,不要含糊其辞。

4

1 回答 1

1

Mhh .. jScrollPane 似乎没有启用/禁用鼠标滚轮的功能,但我认为您可以找到 2 个解决方案:

  1. 不包括 jquery 鼠标滚轮插件(对于 jScrollPane 是可选的)

  2. 使用 jQuery 之后使用 $(**yourcontainer**).jScrollPane();类似的方法取消绑定容器的“鼠标滚轮”事件:

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

编辑 :

这是绑定鼠标滚轮事件的插件代码:

 $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;
   }
 );

这里是插件的描述及其配置:

 * @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
于 2012-07-05T10:55:16.347 回答