在不可滚动的Div内捕捉鼠标滚轮滚动 [英] Catching Mouse Wheel Scroll inside Non-scrollable Div
问题描述
当鼠标位于不可滚动的 div
上时,有没有办法捕获滚动事件?我的意图是通过调整顶部偏移来假装滚动,直到 div
里面的 div
高于视图然后移动内部的顶部偏移 div
到以下 div
的视图。有点像旋转木马,但垂直并通过滚动鼠标滚轮控制。显然,为了捕捉滚动事件,我会使用
Is there a way to catch the scroll event while mouse is positioned over a div
that is not scrollable? My intent is to feign scrolling by adjusting top offset until div
inside of div
is above view then move top offset of inner div
to below view of outter div
. Kind of like a carousel, but vertical and controlled by scrolling of the mouse wheel. Obviously, to catch scroll events, I would use
angular.element(elem).find('.divClass').bind('scroll', function(){...});
来处理实际发生的滚动,但我对滚动实际鼠标滚轮感兴趣就像一个keybind。
to handle scrolling that is actually occurring, but I'm interested in when the actual mouse wheel is scrolled much like a keybind.
推荐答案
你可以使用onwheel事件。请参阅 http://www.w3schools.com/jsref/event_onwheel.asp
you can use the onwheel event. see http://www.w3schools.com/jsref/event_onwheel.asp
某些浏览器使用onmousehweel。有关优秀教程的信息,请参阅 https://www.sitepoint.com/html5-javascript-mouse -wheel /
some browsers use onmousehweel. for a good tutorial see https://www.sitepoint.com/html5-javascript-mouse-wheel/
这篇关于在不可滚动的Div内捕捉鼠标滚轮滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!