Created
June 4, 2013 15:14
-
-
Save joeyfigaro/5706695 to your computer and use it in GitHub Desktop.
Smooth scrolling for internal links
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[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