I encountered a problem when writing an example. Because there is a click on the secondary navigation to load more, resulting in the navigation bar fixed in advance, I wrote the height of the navigation bar from the top of the document to the onscroll before the problem is gone, but there is a navigation bar flickering problem, ask the god to give advice.
this is the code that is fixed in advance
var nav=$(".agenda .erji-nav");
var navST=$(".agenda .erji-nav").offset().top;
$(window).scroll(function(){
if($(document).scrollTop()+80>navST){
nav.addClass("hahaha");
}
else if($(document).scrollTop()+80<=navST){
nav.removeClass("hahaha");
}
});
the navigation bar should be fixed from here
then I wrote var navST=$ (".room. erji-nav"). Offset (). Top; on $(window). Scroll ()
when I was sliding the page, the navigation bar began to flash, I tried several ways but failed, ask the boss to show me the way