I have this case where i wan't to control if the browser window should be scrolled, or if a scrollable div content should be scrolled using mousewheel (in the same scroll event).
Like this:
$('#scrollablediv')[0].addEventListener('wheel', function(e) {
/* try to scroll the browser window instead of the div */
if (someCondition) {
e.preventDefault();
/* this doesn't work */
var event = jQuery.Event('wheel', {deltaY: e.deltaY} );
$('html, body').trigger(event);
}
},{ passive: false }); /* passive: false so i can use e.preventDefault() */
Unfortunately, this doesn't seem to work.
Also, i doesn't wan't to use Window.scrollBy() or Window.scrollTo() because the scroll feels mechanic. It must be a smooth scroll, like the original wheel event.
Note:
I have also tested a solution where i'm changing overflow-y: hidden to overflow-y: scroll using a class, but this requires the visitor to stop scrolling, and starting a new scroll event for it to work. Solution must work using the same scroll event.