Skip to content

Instantly share code, notes, and snippets.

@joeyfigaro
Created June 4, 2013 15:14
Show Gist options
  • Save joeyfigaro/5706695 to your computer and use it in GitHub Desktop.
Save joeyfigaro/5706695 to your computer and use it in GitHub Desktop.
Smooth scrolling for internal links
$('a[href^="#"]').bind('click.smoothscroll',function (e) {
e.preventDefault();
var anchor = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 500, 'swing', function () {
window.location.hash = anchor;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment