mirror of https://github.com/docker/docs.git
				
				
				
			Anchor links fix
This commit is contained in:
		
							parent
							
								
									910dd4c588
								
							
						
					
					
						commit
						02bb0de07d
					
				
							
								
								
									
										20
									
								
								js/docs.js
								
								
								
								
							
							
						
						
									
										20
									
								
								js/docs.js
								
								
								
								
							| 
						 | 
				
			
			@ -175,6 +175,14 @@ $(document.body).scrollspy({
 | 
			
		|||
	offset: navHeight
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
function loadHash(hashObj)
 | 
			
		||||
{
 | 
			
		||||
  // Using jQuery's animate() method to add smooth page scroll
 | 
			
		||||
  // The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
 | 
			
		||||
  $('html, body').animate({
 | 
			
		||||
    scrollTop: $(hashObj).offset().top-80
 | 
			
		||||
  }, 800);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$(document).ready(function(){
 | 
			
		||||
  // Add smooth scrolling to all links
 | 
			
		||||
| 
						 | 
				
			
			@ -188,18 +196,14 @@ $(document).ready(function(){
 | 
			
		|||
 | 
			
		||||
      // Store hash
 | 
			
		||||
      var hash = this.hash;
 | 
			
		||||
      loadHash(hash);
 | 
			
		||||
 | 
			
		||||
      // Using jQuery's animate() method to add smooth page scroll
 | 
			
		||||
      // The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
 | 
			
		||||
      $('html, body').animate({
 | 
			
		||||
        scrollTop: $(hash).offset().top-80
 | 
			
		||||
      }, 800, function(){
 | 
			
		||||
      // Add hash (#) to URL when done scrolling (default click behavior)
 | 
			
		||||
      window.location.hash = hash;
 | 
			
		||||
 | 
			
		||||
        // Add hash (#) to URL when done scrolling (default click behavior)
 | 
			
		||||
        window.location.hash = hash;
 | 
			
		||||
      });
 | 
			
		||||
    } // End if
 | 
			
		||||
  });
 | 
			
		||||
  if (window.location.hash) loadHash(window.location.hash);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue