Skip to content

Instantly share code, notes, and snippets.

@rqreyes
Created June 12, 2018 21:01
Show Gist options
  • Save rqreyes/ae9d8d934fa8f529b991d263e492d01a to your computer and use it in GitHub Desktop.
Save rqreyes/ae9d8d934fa8f529b991d263e492d01a to your computer and use it in GitHub Desktop.
smooth scroll with interruption
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