Created
December 15, 2011 11:40
-
-
Save martinmcwhorter/1480812 to your computer and use it in GitHub Desktop.
jQuery.smoothScroll using HTML5 history API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("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