I want to achieve a navigation bar that fades in after scrolling 100% of the viewport height, but all examples I find use a pixel value instead of viewport height. Is there a way to convert window height into jQuery to make this work? Thank you in advance <3
Instead of 860px, I want it to be equivalent to 100vh
, or equal to the height of the window viewport.
(function($) {
$(document).ready(function(){
$(window).scroll(function(){
if ($(this).scrollTop() > 860) {
$('#navbar').fadeIn(200);
} else {
$('#navbar').fadeOut(200);
}
});
});
})(jQuery);