Skip to content

Instantly share code, notes, and snippets.

@macariojames
Created August 1, 2018 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macariojames/1fce6836541d145aa838faa598ed707f to your computer and use it in GitHub Desktop.
Save macariojames/1fce6836541d145aa838faa598ed707f to your computer and use it in GitHub Desktop.
Anchor link with fixed header scroll with padding
// For FAQ page nav scrolling
function anchorScrollTo() {
$('.anchor li a').on('click', function(e){
e.preventDefault();
var scrollTo = $($(this).attr('href'));
var headerHeight = $('.page_header').height();
console.log(scrollTo, headerHeight);
$('html,body').animate({
scrollTop: scrollTo.offset().top - headerHeight},
'slow');
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment