Created
June 12, 2018 21:01
-
-
Save rqreyes/ae9d8d934fa8f529b991d263e492d01a to your computer and use it in GitHub Desktop.
smooth scroll with interruption
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
var page = $("html, body"); | |
$('a[href*="#"]').click(function(e) { | |
page.on("scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove", function(){ | |
page.stop(); | |
}); | |
page.animate({ scrollTop: $(this).position().top }, 'slow', function(){ | |
page.off("scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove"); | |
}); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment