I'm having trouble with disabling the scroll bar on my website when the menu overlay is active (class: .overlay). I created a menu overlay and I would like the scroll bar to be disabled when the overlay is visible. Similar to this Just disable scroll not hide it?
So I would like to disable the scroll bar, not hide it. What I understand so far: Basically what I need to do is to add inline CSS to the html when the overlay is on display: block and remove the inline CSS when the overlay is on display: none;
I tried multiple solutions given on Stackoverflow, but no result so far. This was my latest solution, which didnt work in the end:
if( $(".overlay").css('display') == 'block') {
$('html').css('position','fixed');
$('html').css('overflow-y','scroll');
$('html').css('width','100%');
} else {
$('html').css('position','');
$('html').css('overflow-y','');
$('html').css('width','');
}
Above is based on this: div display if block jquery
Here is my website (under development):
http://www.wouterpasman.com/view/
The menu overlay is activated when you click the menu button in the top right corner. Goal: When the overlay is active, the scroll bar should be temporarily disabled, but still visible.
Thanks for your assistance!