Skip to content

Instantly share code, notes, and snippets.

@EliaECoyote
Last active September 7, 2017 21:35
Show Gist options
  • Save EliaECoyote/2f173e340d6e19d9a6ab0175d5dcb9f9 to your computer and use it in GitHub Desktop.
Save EliaECoyote/2f173e340d6e19d9a6ab0175d5dcb9f9 to your computer and use it in GitHub Desktop.
jquery smooth scroll
export function smoothScrollingTo(target) {
$('html,body').animate({ scrollTop:$(target).offset().top }, 500);
}
/** smooth scroll on anchor */
/*
$('a[href*=\\#]').on('click', function(event){
event.preventDefault();
smoothScrollingTo(this.hash);
});
*/
/** smooth scroll on startup */
/*
$(document).ready(function(){
smoothScrollingTo(location.hash);
});
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment