JSFiddle - React, Tailwind, and code Playground
HTML
<div id="output"></div>
<div id="output2"></div>
<div id="abs">
Absolutely positioned div
<br />
<br />
<br />
<br />
That
<br />
<br />
<br />
Is
<br />
<br />
<br />
Really
<br />
<br />
<br />
Really
<br />
<br />
<br />
Really
<br />
<br />
<br />
Really
<br />
<br />
<br />
Long
</div>
CSS
body { min-height: 1200px; }
div#abs {
position: absolute;
top: 50px;
left: 30px;
height: 400px;
width: 200px;
background-color: gray;
overflow: scroll;
}
JavaScript
$('#abs').bind('mousewheel DOMMouseScroll', function(e) {
var scrollTo = 0;
e.preventDefault();
if (e.type == 'mousewheel') {
scrollTo = (e.originalEvent.wheelDelta * -1);
console.log("w"+e.originalEvent.wheelDelta);
}
else if (e.type == 'DOMMouseScroll') {
scrollTo = 40 * e.originalEvent.detail;
console.log("d"+e.originalEvent.detail);
}
$(this).scrollTop(scrollTo + $(this).scrollTop());
});