Skip to content

Instantly share code, notes, and snippets.

@jtulk
Last active August 29, 2015 14:05
Show Gist options
  • Save jtulk/71eaca2c85fb97795112 to your computer and use it in GitHub Desktop.
Save jtulk/71eaca2c85fb97795112 to your computer and use it in GitHub Desktop.
Smoothscroll intrapage links w/ .scroll-link class
$('nav').find('a').on 'click', ->
that = $(this)
target = $(this.hash)
if !target.length
target = $('[name=' + this.hash.slice(1) +']')
$('html,body').animate({
scrollTop: target.offset().top
}, 1000, ->
#update the url hash
window.location.hash = that.attr('href')
)
return false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment