JSFiddle - React, Tailwind, and code Playground
by Emily Humphrey
HTML
<div>Scroll to bottom of each div</div>
<div id="good">
<p>Good</p>
End of Div
</div>
<div id="bad">
<p>Bad</p>
End of Div
</div>
CSS
body { min-height: 1200px; padding: 30px; }
p { height: 500px; }
div#bad {
position: absolute;
top: 70px;
left: 330px;
height: 200px;
width: 200px;
background-color: lightgray;
overflow: scroll;
}
div#good {
position: absolute;
top: 70px;
left: 30px;
height: 200px;
width: 200px;
background-color: gray;
overflow: scroll;
}
JavaScript
$('#good').bind('mousewheel DOMMouseScroll', function(e) {
var scrollTo = null;
if (e.type == 'mousewheel') {
scrollTo = (e.originalEvent.wheelDelta * -1);
}
else if (e.type == 'DOMMouseScroll') {
scrollTo = 40 * e.originalEvent.detail;
}
if (scrollTo) {
e.preventDefault();
$(this).scrollTop(scrollTo + $(this).scrollTop());
}
});