Skip to content

Instantly share code, notes, and snippets.

@MikeMcChillin
Last active December 15, 2015 22:29
Show Gist options
  • Save MikeMcChillin/5333739 to your computer and use it in GitHub Desktop.
Save MikeMcChillin/5333739 to your computer and use it in GitHub Desktop.
Scrollio smooth scrolls to a target, with speed & easing. Perfect for in-page navigation.
#######################
# Smooth scroll
#######################
scrollio = (target, speed) ->
$("html, body").animate
scrollTop: $(target).offset().top
, speed, "easeInOutExpo"
## Set up an event trigger for scrollio
nav_links = $('nav a')
nav_links.click (e) ->
e.preventDefault()
target = $(this).attr('href')
scrollio(target, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment