Scrolltop动画后的滚动/滚动条锁定 [英] Scrolling/Scrollbar Locks After Scrolltop Animation

查看:148
本文介绍了Scrolltop动画后的滚动/滚动条锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些锚点链接到页面中的特定部分(使用井号标签),还有一些锚点可以滚动到文档窗口的顶部或底部.

I've got a few anchors that link to specific sections (using hashtags) within the page, and ones that scroll to the top or bottom of the document window.

$("html, body").animate({ scrollTop: $(document).height() }, 2000);

但是,一旦动画和滚动到达目的地并完成后,文档滚动和滚动条似乎会禁用几秒钟.例如,如果单击转到页面底部"链接,我的文档窗口将正确滚动到页面底部.当我尝试向上滚动时,它会以抖动的方式上下摆动,并允许我稍后滚动一些尝试.

However, as soon as the animation and scrolling has reached it's destination and completed, the document scrolling and scrollbar seem to disable for a few seconds. For example, if click a "Go to bottom of page" link, my document window will scroll to the bottom of the page correctly. As soon as I try to scroll back up, it jiggles a bit up and down in a jittery motion and allows me to scroll a few tries later.

关于什么可能导致这种情况的任何提示?

Any tips on what might be causing this?

推荐答案

这个线程很旧,但是我遇到了这个问题,在任何地方都没有答案,但这是一个解决方案:

This thread is old, but I ran into this and there arent answers anywhere, but here is a solution:

$(window).bind("mousewheel", function() {
    $("html, body").stop();
});

如果用户在执行动画时使用滚动条,则会停止动画.

if the user uses the scrollbar while the animation is executing, it stops the animation.

这篇关于Scrolltop动画后的滚动/滚动条锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆