【问题标题】:scroll to top using .animate if at top stop - jquery如果在顶部停止使用 .animate 滚动到顶部 - jquery
【发布时间】:2012-05-08 15:29:38
【问题描述】:

我使用 .animate 滚动到页面顶部,但是如果用户已经在顶部或非常靠近它并且他们单击 .proj-tile 他们将无法再次向下滚动 1200 毫秒有没有办法到达顶部时停止脚本停止?

 $('.proj-tile').click(function()   {
    $('html, body').animate({ scrollTop: '+0'   }, 1200);
});

干杯

【问题讨论】:

    标签: jquery jquery-animate jquery-scrollable


    【解决方案1】:

    尝试添加一个条件来检查滚动的高度并相应地调用动画,

    $('.proj-tile').click(function()   {
        if($(window).scrollTop() >= 300) { //has scrolled considerably to animate
            $('html, body').animate({ scrollTop: '+0'   }, 1200);
        }
    });
    

    【讨论】:

    猜你喜欢
    • 2023-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-22
    • 2020-06-01
    • 2015-03-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多