Skip to content

Instantly share code, notes, and snippets.

@willwright82
Last active August 29, 2015 14:04
Show Gist options
  • Save willwright82/3f9e6805a33cc6eef313 to your computer and use it in GitHub Desktop.
Save willwright82/3f9e6805a33cc6eef313 to your computer and use it in GitHub Desktop.
Smooth Scroll
/* Smooth Scrolling */
$('a.scroll[href*=#]:not([href=#])').on('click', function(e) {
// prevent default anchor click behavior
target = this.hash;
e.preventDefault();
// animate
$('html, body').animate({
scrollTop: $(this.hash).offset().top - 60
}, 1000, function() {
// when done, add hash to url
// (default click behaviour)
// window.location.hash = target;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment