Skip to content

Instantly share code, notes, and snippets.

@rob1121
Created July 21, 2016 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rob1121/230be9957604f4e616540d97f36534b0 to your computer and use it in GitHub Desktop.
Save rob1121/230be9957604f4e616540d97f36534b0 to your computer and use it in GitHub Desktop.
scroll smoothly
$('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