Last active
January 24, 2017 22:16
-
-
Save terehof/4b64b83a56fe5bcf5167 to your computer and use it in GitHub Desktop.
jq snippet smooth scrolling for anchors
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
$(document).ready(function() { | |
$("a.scrollto").click(function () { | |
elementClick = $(this).attr("href") | |
destination = $(elementClick).offset().top; | |
$("html:not(:animated),body:not(:animated)").animate({scrollTop: destination}, 1100); | |
return false; | |
}); | |
}); | |
// add "<a href="#section-2" class="scrollto">Section 2</a>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment