Skip to content

Instantly share code, notes, and snippets.

@martinmcwhorter
Created December 15, 2011 11:40
Show Gist options
  • Save martinmcwhorter/1480812 to your computer and use it in GitHub Desktop.
Save martinmcwhorter/1480812 to your computer and use it in GitHub Desktop.
jQuery.smoothScroll using HTML5 history API
$("a[data-smoothscroll], [data-smoothscroll] a").click(function() {
history.pushState({path: this.path}, '', this.href);
$.smoothScroll({scrollTarget: location.hash, offset: -65});
return false;
});
$(window).bind('popstate', function() {
$.smoothScroll({scrollTarget: location.hash, speed: 0, offset: -65});
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment