javascript - 在不可滚动的 Div 内捕获鼠标滚轮滚动

标签 javascript jquery angularjs event-handling jquery-events

当鼠标位于不可滚动的 div 上时,有没有办法捕获滚动事件?我的目的是通过调整顶部偏移量来假装滚动,直到 div 内部的 div 位于 View 上方,然后将内部 div 的顶部偏移量移动到 View 下方外部 div。有点像旋转木马,但垂直并通过滚动鼠标滚轮控制。显然,为了捕获滚动事件,我会使用:

angular.element(elem).find('.divClass').bind('scroll', function(){...});

处理实际发生的滚动,但我感兴趣的是实际的鼠标滚轮何时像按键绑定(bind)一样滚动。

最佳答案

您可以使用 onwheel 事件。请参阅http://www.w3schools.com/jsref/event_onwheel.asp

某些浏览器使用 onmousehweel。有关良好的教程,请参阅 https://www.sitepoint.com/html5-javascript-mouse-wheel/

关于javascript - 在不可滚动的 Div 内捕获鼠标滚轮滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40107394/

相关文章:

javascript - UI-Router StateChange 但 View UI 不刷新

javascript - 如何使用 angularjs 过滤器在标题上添加排序?

angularjs - angular2 http 类型错误

javascript - jQuery 弹出窗口,将其更改为在框架或 ajax 中加载页面

javascript - 使用不同的 json 数据填充不同的选择框

jquery - 中心 SVG 图表宽度 jQuery

javascript - 我可以在 ng-bind 中创建 JavaScript 对象吗?

javascript - 将参数从 angularJs 发送到 php symfony2 api

javascript - sencha Controller 文件中的按钮点击不起作用

javascript - 用于检查 App Store 中应用程序名称可用性的实用程序