I have a site built on selfhosted Wordpress (Divi). It changes the top menu logo on scroll. I need the logo to change when the site shows the fixed header instead the primary top menu. I use this JQuery script:
<script>
jQuery(window).scroll(function () {
if (jQuery(window).scrollTop() > 50) {
jQuery('#logo').attr('src','link_to_fixed_header_logo')
} else {
jQuery('#logo').attr('src','link_to_primary_top_menu_logo')
}
});
</script>
It works fine on the home page, the logo changes when the fixed header appears (and changes background color for the logo). However, there is one bug on all other pages. The fixed header shows a little bit lower, and because of that, the logo changes first, and then the background changes. How can I fix it?
I think it can probably be done in two ways, either two versions of script can be made or one can make fixed header show at the same point on all the pages.