-4
My code makes when I scroll down, the logo is shown. And when I scroll back, it hides.
It happens that when I’m in the middle of the page, with it active, and I restart the page - refresh - the browser throws me in the middle of the page where I was and the logo does not appear. Even though I’m almost at the end of the site. Only after I tap scroll that he displays.
How to solve this?
My code:
$(document).bind('ready load scroll resize', function() {
if($(window).scrollTop() > 100) {
$(".logoHeader").addClass("logoHeaderHide");
$(".logoNav").addClass("logoNavShow");
} else {
$(".logoHeader").removeClass("logoHeaderHide");
$(".logoNav").removeClass("logoNavShow");
}
});
Exchange the
document
forwindow
... the only event heard bydocument
on the list you putscroll
, i.e., the others (ready, load and resize) are there without any effect.– Sam