JQUERY,scrollTo,向下滚动后,页面不允许我向上滚动一秒钟...Y?
我使用以下 JQUERY 将偶数附加到标题中的链接,该链接基本上滚动到页面底部:
$('#comment-count-btn').click(function(){
$('html,body').scrollTo('#comment-wrapper', 500);
});
问题是,它一直滚动到页面底部(这是正确的),但是然后,当我尝试向上滚动一点时,滚动条会跳跃,就好像它被锁定了一点。
有什么想法吗?
I'm using the following JQUERY to attach an even to a link in the header, which essentially scrolls to the bottom of the page:
$('#comment-count-btn').click(function(){
$('html,body').scrollTo('#comment-wrapper', 500);
});
Problem is, that it scrolls all the way to the bottom of the page (which is correct), but then when I try to scroll up a tad, the scroll bar jumps, as if it's locked for a little bit.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试在 click() 函数末尾添加
return false;
。另外,尝试仅滚动到“body”,而不是同时滚动到 html 和 body。这可能会让scrollTo 感到困惑。Try adding
return false;
in the end of click() function. Also, try scrollTo only to the 'body' not both html and body. It maybe confusing scrollTo.尝试使用 console.log 跟踪您的点击,很可能您的元素被点击了多次。
另外,如果您有滚动捕获位置,请确保单击位于滚动之外。这就是我解决同样问题的方法。
Try to trace your click using console.log, most likely your element is being clicked multiple times.
Also, if you have on scroll capturing the position make sure that the on click is outside of the on scroll. That's how I fixed this same issue.
让点击事件脱离滚动功能对我有用
Having the click event out of the scroll function worked for me