Home › Forums › CSS › Prevent body scrolling when the user scrolls on fixed position div › Reply To: Prevent body scrolling when the user scrolls on fixed position div
January 24, 2018 at 6:53 am
#265961
leocavalcante
Participant
$('#fixed').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());
}
});