stop mousewheel's continued effect

2019-09-11 04:40发布

问题:

How can I stop this effect:

I'm scrolling in a div using the mousewheel, and when I reach the bottom of the scroll content, then mousewheel continues the scrolling on the body (or on the first scrollable element, that wraps my div).

回答1:

This continuum scroll also bothers me on websites..

The theory would be something as:
The element you want to scroll, must have an JavaScript event listener of scroll attached to it, so when the scroll is at zero and the user scrolls up you OR the element is scrolled at maximum and the user scrolls down, then you return false

Usign jQuery, something like:

$(".scrollable").scroll(function(){
 // use something like if( $(this).scrollTop() .... ), then return false
});