Created
August 1, 2018 19:04
-
-
Save macariojames/1fce6836541d145aa838faa598ed707f to your computer and use it in GitHub Desktop.
Anchor link with fixed header scroll with padding
This file contains 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
// 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