Catching Mouse Wheel Scroll inside Non-scrollable Div

蹲街弑〆低调 提交于 2019-12-12 03:49:28

问题


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(){...});

to handle scrolling that is actually occurring, but I'm interested in when the actual mouse wheel is scrolled much like a keybind.


回答1:


you can use the onwheel event. see http://www.w3schools.com/jsref/event_onwheel.asp

some browsers use onmousehweel. for a good tutorial see https://www.sitepoint.com/html5-javascript-mouse-wheel/



来源:https://stackoverflow.com/questions/40107394/catching-mouse-wheel-scroll-inside-non-scrollable-div

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!