Skip to content

Instantly share code, notes, and snippets.

@josuecau
Forked from daviferreira/smooth-scrolling.coffee
Last active May 27, 2016 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save josuecau/9647154 to your computer and use it in GitHub Desktop.
Save josuecau/9647154 to your computer and use it in GitHub Desktop.
# based on http://www.paulund.co.uk/smooth-scroll-to-internal-links-with-jquery
$ ->
$('a[href*=#]:not([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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment