Skip to content

Instantly share code, notes, and snippets.

@jimmynotjim
Created May 4, 2012 00:16
Show Gist options
  • Save jimmynotjim/2590626 to your computer and use it in GitHub Desktop.
Save jimmynotjim/2590626 to your computer and use it in GitHub Desktop.
Animated Scrolling
Add a class of .scrollPage to any trigger link on the page and script will run when the link is clicked.
$('.scrollPage').click(function() {
var elementClicked = $(this).attr("href");
var destination = $(elementClicked).offset().top;
$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-20}, 500 );
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment