Created
August 28, 2018 06:18
-
-
Save Lysindr/9022b251e6617b6f009d71403ebaee5b to your computer and use it in GitHub Desktop.
Scroll top with stoping animation if user scroll manualy when animation in progress
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
// Scroll to top | |
/* | |
* When you click and animation start, if you scroll with mouse, keybord hotkeys in same moment - animation will stop. | |
/* | |
$(".scroll-top-class").click(function(e) { | |
e.preventDefault(); | |
$('html, body').on("scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove", function(){ | |
$('html, body').stop(); | |
}); | |
$('html, body').animate({ scrollTop: $("#top").offset().top }, 1000, function(){ | |
$('html, body').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