I have a content navigation bar for my website which is supposed to show only after the user has scrolled 800px down the page. I'm using this JS code to implement this behaviour:
$(document).scroll(function() {
var y = $(this).scrollTop();
if (y > 800) {
$("#pn-navigation-bar").fadeIn();
} else {
$("#pn-navigation-bar").fadeOut();
}
});
However, whenever the page initially loads the navigation bar still shows up but disappears after the user scrolls a little. This is demonstrated in this video here and the images below:
But the JS code specifies not to show the div before a certain amount has been scrolled. What can I do to fix this?

