admin管理员组文章数量:1356764
How can i stop the scrollTop function when the user scrolls himself? If i scroll now while the scrollTop function the whole scrolling glitches out.
$(document).ready(function (){
$(".header-arrow-down").click(function (){
$('html, body').animate({
scrollTop: $(".page-1").offset().top
}, 1000);
});
$("body").scroll(function() {
alert("scrolling");
});
});
I tried this so far but the alert scrolling isnt showing up for me and i can't find a solution on google so im asking it here.
I hope someone knows how to fix this thanks!
How can i stop the scrollTop function when the user scrolls himself? If i scroll now while the scrollTop function the whole scrolling glitches out.
$(document).ready(function (){
$(".header-arrow-down").click(function (){
$('html, body').animate({
scrollTop: $(".page-1").offset().top
}, 1000);
});
$("body").scroll(function() {
alert("scrolling");
});
});
I tried this so far but the alert scrolling isnt showing up for me and i can't find a solution on google so im asking it here.
I hope someone knows how to fix this thanks!
Share Improve this question asked Oct 15, 2014 at 9:37 StefanStefan 1,9057 gold badges25 silver badges38 bronze badges2 Answers
Reset to default 7you need to unbind or stop the animation when user scrolls, sth like
$("html, body").bind("scroll mousedown DOMMouseScroll mousewheel keyup", function(){
$('html, body').stop();
});
Hey I just wrote that code today for a project I'm working on:
$('body,html').bind('scroll mousedown wheel DOMMouseScroll mousewheel keyup', function(e){
if (e.which > 0 || e.type == "mousedown" || e.type == "mousewheel"){
$("html,body").stop();
}
});
本文标签: javascriptStop ScrollTop function when user scrolls jqueryStack Overflow
版权声明:本文标题:javascript - Stop ScrollTop function when user scrolls jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743958047a2568495.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论