Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Smoothly jump to anchors
  2. // https://gist.github.com/HoundstoothSTL/5510082
  3. $(document).ready(function($) {
  4.     $('a[href*=#]:not([href=#])').click(function(){
  5.     if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') || location.hostname == this.hostname){
  6.         var target = $(this.hash),
  7.         headerHeight = $("header").height() + 10; // Get fixed header height
  8.  
  9.         target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  10.  
  11.         if (target.length){
  12.             $('html,body').animate({
  13.                 scrollTop: target.offset().top - headerHeight
  14.             }, 1500);
  15.         return false;
  16.         }
  17.     }
  18.     });
  19. })/*(jQuery)*/;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement