The Pure JS Solution
Everything is very simple: just use addEventListener
for scrolling event.
document.body.addEventListener('scroll', function( event ) {
console.log(';{};');
} );
And make body
scrollable with CSS:
:root {
overflow: hidden;
}
body {
overflow-y: scroll;
max-height: 100vh;
}
I do not know why simple handler assignment doesn't work. If you know why — please, tell me.
document.body.onscroll = function( event ) {
console.log('You will never see this message.');
};
Also you could do this:
document.body.onwheel = function( e ) {
...
};
This event will be triggered only when you using a wheel (for me that wasn't obvious, actually), so if you will scroll your page with a scrollbar it will not trigger.