You need to remove the overflow from the body of the page so nothing can be scrolled.
$(window).on('DOMContentLoaded', function() {
if ($('#preloader').length) {
$('#preloader').delay(2000).fadeOut('slow');
document.body.style.overflowY = "hidden"; // remove overflow from body
$('body').addClass('preload_active'); // add preload_active class
}
});
If using the addClass
option then you'll need
.preload_active {
overflow-y: hidden;
}
in your CSS.
You will need something to remove the hidden value though. You can also add a class to the body and in the CSS declare overflow-y: hidden
on this class. Again, you will need some logic that removes the class when the preloader.length === 0
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…