Created
April 3, 2014 22:07
-
-
Save rohmann/9963871 to your computer and use it in GitHub Desktop.
Target an a tag normally used for anchor navigation. Provide an offset element, and it can do an animated scroll and compensate for fixed headers
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
jQuery(function($){ | |
$('section a').click(function(e){ | |
e.preventDefault(); | |
$('html,body').animate({ | |
scrollTop: $('#' + $(this).attr('href').split("#").slice(-1)[0] ).offset().top - $('header').height() | |
},700 ,'swing'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment