I wanted my navigation to behave like a "sticky nav" and rather than use a plugin, so I tried to just come up with a solution myself.
It seemed like the most appropriate thing to do is just change all the css values with jquery in a conditional statement.
Here was my solution to this problem:
$(window).scroll(function() {
if($(document).scrollTop() > 50)
{
$('.site-header').css("height", "48px");
$('.site-title a').css("background-size", "45px 45px");
$('.genesis-nav-menu > li').css("line-height", "50px");
$('.genesis-nav-menu .sub-menu').css("top", "0").css("margin-top", "48px");
}
else
{
$('.site-header').css("height", "100px");
$('.site-title a').css("background-size", "101px 101px");
$('.genesis-nav-menu > li').css("line-height", "100px");
$('.genesis-nav-menu .sub-menu').css("top", "100").css("margin-top", "100px");
}
});
The margin-top
funny business is to correctly align the sub-menus. I'm sure there's a better way to do that. However, my question is: is there a more performant way to do this?