Created
          November 24, 2015 16:06 
        
      - 
      
- 
        Save lenagroeger/e275fdef209f08b78b14 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | $(document).ready(function() { | |
| $('.nav a').click(function(e) { | |
| e.preventDefault(); | |
| var curInx = this.hash; | |
| var target = $(curInx); | |
| var targetOffset = target.offset().top; | |
| $("body").animate({scrollTop: (targetOffset)}, 400, function() { | |
| location.hash = curInx; | |
| }); | |
| }); | |
| $(window).scroll(function() { | |
| var sticky = function(index) { | |
| $('li').removeClass('active'), $('.' + index + '-nav').addClass('active'); | |
| }; | |
| $('.section').each(function(){ | |
| var cur = $(this); | |
| var curTop = cur.offset().top; | |
| var curInx = cur.attr("id"); | |
| var sidebarTop = $('.'+curInx+'-nav').offset().top - 60; | |
| if (sidebarTop > curTop) { | |
| sticky(curInx); | |
| } | |
| }); | |
| }); | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment