Strange issue with jquery sticky menu
I got strange problem. I created sticky menu with jquery. Everything works
fine on first page, but on any other page there is a problem. When i
scroll down to my point, where menu becomes sticky, it automatically goes
back to top (with some margin from top). So basically i scroll down and
then it scrolls up . This code is cleaned up, i have also added fade
effects on hover, but that is not what causes the problem.
var navoffset = $('nav').offset().top;
navoffset = navoffset+80;//offset=10 + half of menu height
$(window).scroll(function(){
if( $(window).scrollTop() > navoffset ){
$('nav').css({position: 'fixed' , top: '-90px'}); // stick half of menu
}else
{
$('nav').css({position: 'relative' , top: '0px'}); //set back
}
});
EDIT: Oh, and when i open inspect element, everything works fine on all
pages.
No comments:
Post a Comment