javascript - jScrollPane 我如何删除鼠标滚轮功能

标签 javascript jquery scrollbar jscrollpane

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

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

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

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

最佳答案

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

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

  2. 使用 jQuery 后,解除容器的“鼠标滚轮”事件绑定(bind) $(**yourcontainer**).jScrollPane(); 像这样:

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

编辑:

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

 $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

关于javascript - jScrollPane 我如何删除鼠标滚轮功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11342431/

相关文章:

javascript - 只读在 jquery 中的变化

显示选择选项时的 JavaScript 事件?

javascript - 构建一个可以通过热键激活的 Chrome 扩展程序

javascript - typescript 计算数组中的重复项并按每个项目的计数对结果进行排序

javascript - 如何从异步调用返回响应?

javascript - jspContainer 内缺少 div jspVerticalBar

html - 表格单元格内的 CSS 100% 宽度滚动条 (overflow-x)

css - 如何在不更改浏览器滚动条的情况下设置页内滚动条的样式?

javascript - 如何连接数组不可变的方式JS

javascript - model.toJSON() 返回空对象