Created
June 4, 2019 10:41
-
-
Save Patrick64/44ba3f218d40ee00338f4f12c9798b11 to your computer and use it in GitHub Desktop.
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
function smoothAnchorScroll() { | |
// https://www.abeautifulsite.net/smoothly-scroll-to-an-element-without-a-jquery-plugin-2 | |
$('a[href*="#"]').on('click', function(event) { | |
if (this.getAttribute('href') == "#") return; | |
var target = $(this.getAttribute('href')); | |
if( target.length ) { | |
// event.preventDefault(); | |
$('html, body').stop().animate({ | |
scrollTop: target.offset().top | |
}, 1000); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment