Last active
December 15, 2015 22:29
-
-
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.
This file contains hidden or 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
####################### | |
# 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