Last active
September 7, 2017 21:35
-
-
Save EliaECoyote/2f173e340d6e19d9a6ab0175d5dcb9f9 to your computer and use it in GitHub Desktop.
jquery smooth scroll
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
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