javascript - Jquery scroll, top offset for active class -


can me please 1 thing can't manage?

i have used scrolling-nav.js top menu on website - interior, exterior etc. http://lukaszradwan.com/www_architect/services.php

now set offset using code

$(window).scroll(function() { if ($(".navbar").offset().top > 130) {     $(".navbar-fixed-top").addclass("top-nav-collapse"); } else {     $(".navbar-fixed-top").removeclass("top-nav-collapse"); } });  $(function() { $('a.page-scroll').bind('click', function(event) {     var $anchor = $(this);     $('html, body').stop().animate({         scrolltop: $($anchor.attr('href')).offset().top - 130     }, 1500, 'easeinoutexpo');     event.preventdefault(); }); }); 

but when click example exterior, active class not working @ position.

i tried use method form topic, "js" knowledge poor. jquery scroll, change navigation active class page scrolling, relative sections

thanks in advance.

right now, active class applied when top offset of section 0. can change other value 130 using jquery. add code:

$(window).scroll(function(){     /* id of sections corresponding top nav menu */     var scroll_sections = []     $('a.page-scroll').each(function(){       scroll_sections.push($(this).attr('href'));     })      (i in scroll_sections)     {          /* instead of 0, if top position offset of section 130 or less,          add active class section in nav menu */       if ($(scroll_sections[i]).position().top <= $(window).scrolltop() + 130)        {         $('nav li.active').removeclass('active');         $('nav a').eq(i).parent().addclass('active');       }     } }); 

Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -