Last active
August 29, 2015 14:11
-
-
Save ckhatton/26e2d03ee8159ea3e7c8 to your computer and use it in GitHub Desktop.
A scroll-to function. Detects if a manual scroll has occurred during the animation, and stops, to prevent a glitchy clash of actions.
This file contains 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(element, within) { | |
$(within).bind('mousedown DOMMouseScroll mousewheel', function(){ | |
$(this).stop(); | |
}); | |
$(within).animate({ | |
scrollTop: Math.ceil($(element).position().top) | |
}, 1500, "easeOutQuart", function(){ | |
$(this).unbind('mousedown DOMMouseScroll mousewheel'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment