Created
March 31, 2012 23:46
-
-
Save daviferreira/2269793 to your computer and use it in GitHub Desktop.
Smooth scrolling for anchor '#' links using jQuery and CoffeeScript
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
# based on http://www.paulund.co.uk/smooth-scroll-to-internal-links-with-jquery | |
$ -> | |
$('a[href^="#"]').on 'click.smoothscroll', (e) -> | |
e.preventDefault() | |
target = @hash | |
$target = $(target) | |
$('html, body').stop().animate { | |
'scrollTop': $target.offset().top | |
}, 500, 'swing', -> | |
window.location.hash = target |
Thanks!
Works fine, simple and easy ;) Thank you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works great! Thanks