Skip to content

Instantly share code, notes, and snippets.

@jasonyost
Created December 19, 2014 02:17
Show Gist options
  • Save jasonyost/c07a296859706c563ab5 to your computer and use it in GitHub Desktop.
Save jasonyost/c07a296859706c563ab5 to your computer and use it in GitHub Desktop.
jQuery Smooth Scroll
$("a[href*=#]:not([href=#])").click ->
if location.pathname.replace(/^\//, "") is @pathname.replace(/^\//, "") or location.hostname is @hostname
target = $(@hash)
target = (if target.length then target else $("[name=" + @hash.slice(1) + "]"))
if target.length
$("html,body").animate
scrollTop: target.offset().top
, 1000
false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment