Created
October 6, 2016 16:13
-
-
Save maxxcrawford/c4a6a2828fefa13c38eaa053849af632 to your computer and use it in GitHub Desktop.
Smooth scroll js
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
function scrollTo(selector, offset){ | |
target = $(selector); | |
if (target.length) { | |
var targetOffset = target.offset().top; | |
if (offset.length){ | |
targetOffset = targetOffset - offset; | |
} | |
$('html, body').animate({ | |
scrollTop: targetOffset | |
}, 'slow'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment