如何获得自上而下的自动无限滚动效果?

时间:2019-03-03 12:18:15

标签: javascript jquery html scroll infinite

对于一个客户,我必须建立一个完全像这样的网站:

http://thisisclimate.com/

我为滚动部分找到了一些插件。这是无限滚动,但是当到达页面底部时,您应该从顶部重新加载页面。

有人对我如何构建它有任何想法吗?

我尝试使用以下代码:

 $( document ).ready(function() {

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

setTimeout(function() {
   $('html, body').animate({scrollTop:0}, 0); 
},0);

var scrolltopbottom =  setInterval(function(){

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

    setTimeout(function() {
       $('html, body').animate({scrollTop:0}, 0); 
    },0);
},0); 
});

这是HTML的样子:

<body>

<img src="https://via.placeholder.com/500" />
<p>Text</p>
<img src="https://via.placeholder.com/900" />

</body>

0 个答案:

没有答案