向下滚动当前视口的高度 [英] scroll down page by the height of current viewport

查看:89
本文介绍了向下滚动当前视口的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,其中有一个固定位置的按钮,单击该按钮应计算视口的高度,然后向下滚动该高度. IE.到下一个视口.当用户到达没有更多滚动空间的位置时,我想隐藏此按钮.不确定如何执行此操作,到目前为止,我已经知道了:

I have a page in which I have a fixed positioned button, which when clicked should calculate the height of the viewport, and then scroll down the page by that height. ie. to the next viewport. When the user reaches the point when there is no more room to scroll I want to hide this button. Not sure how to do this, so far I have this:

$(document).on('click', '.next-viewport-down', function(event){                        
                     event.preventDefault();
                     var viewportHeight = $(window).height();

                         $('html, body').stop(true,true).animate({
                                 .....
                             }, 2000);
            });

推荐答案

尝试一下.

$(document).on('click', '.next-viewport-down', function(event){                        
    event.preventDefault();
    var viewportHeight = $(window).height();

    $('html, body').animate({
        scrollTop: viewportHeight,
        complete: function () {
            //Hide your button here
        }
    }, 2000);
});

这篇关于向下滚动当前视口的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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