javascript - Page Scrolling jQuery Navigation -


i building website can viewed here: argit.bounde.co.uk

i have done majority of content , trying work on navigation. have 3 navigation bars (only 1 ever visible) , need method work no matter showing. if resize browser make window narrower show second, , when scroll navigation appears third.

i have got working fashion problem when click link jumps wants go momentarily, returns , scrolls meant to. because of "href="#target" have left in nav. have tried including "return false" if broswer doesnt support js navigation doesnt work @ all.

the next problem want way make target "over". when click link scrolls selected 1 , nav updates link "over" passes them. want when user scrolling , down page, if click link want link "over" (and respective links other navigations) , not affected scroll checks override it.

the solution using onclick navigation below, know there plug ins kind of thing want write myself can better understanding of jquery. im not sure if solution using @ moment one, if not please advise me:

function navigation() {      $('html, body').stop().animate({         scrolltop: $($(this).attr('href')).offset().top     }, 1500); } 

the solution using scrolling checks found accident , below, works on riding equation above , quite simple. there action fix navigation when scrolling.

function navcheck() {  var documentheight = $(document).height(); var windowheight = $(window).height(); var windowtop = $(window).scrolltop() + 100;  var navtop = $("#scrollanchor").offset().top; var mobiletop = $("#mobileanchor").offset().top; var mobileheight = $("#mobileanchor").height();  var overviewtop = $("#slider").offset().top; var biotop = $("#bio").offset().top; var solutionstop = $("#solutions").offset().top; var experiancetop = $("#experiance").offset().top; var contacttop = $("#contact").offset().top;  if($(window).scrolltop() > navtop) {    $("#leftfixer").addclass("leftfix");     } else {        $("#leftfixer").removeclass("leftfix"); }  if($(window).width() < 1200){     if(windowtop - 90 > mobiletop + mobileheight) {         $("#mobilefix").slidedown();         } else {             if(windowtop - 96 <= mobiletop) {                 $("#mobilefix").hide();             }         }      } else {         $("#mobilefix").slideup(); }  $("li").removeclass("over"); $("li.navoverview").addclass("over");   if(windowtop > biotop) {     $("li").removeclass("over");     $("li.navbio").addclass("over"); }  if(windowtop > solutionstop) {     $("li").removeclass("over");     $("li.navsolutions").addclass("over"); }  if(windowtop > experiancetop) {     $("li").removeclass("over");     $("li.navexperiance").addclass("over"); }  if(windowtop > contacttop || windowtop > documentheight - windowheight) {     $("li").removeclass("over");     $("li.navcontact").addclass("over"); } } 

this first post here if have missed out information im sorry! have looked similar posts seems people go plugin when doing kind of thing. thank you

update: page jumping anchor has been fixed

normally, if use javascript scroll page, put return false; after calling function. prevents page scrolling momentarily anchor.

something like

function navigation() {      $('html, body').stop().animate({         scrolltop: $($(this).attr('href')).offset().top     }, 1500);     return false; } 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -