连续循环页面(非无限滚动)继续

时间:2018-10-15 09:03:10

标签: loops scroll infinite continuous

我尝试使用下面的上一个问题Continuous Looping Page (Not Infinite Scroll)中的代码来使循环起作用,并且该循环在本地运行良好,但在服务器必须下载图像的实时环境中却无法使用-内容从底部消失页面,然后不包含在循环中。在激活循环之前如何加载所有内容?

$('document').ready(function() {

 // We need to duplicate the whole body of the website so if you scroll down you can see both the bottom and the top at the same time. Before we do this we need to know the original height of the website.
 var origDocHeight = document.body.offsetHeight;

 // now we know the height we can duplicate the body    
 $("body").contents().clone().appendTo("body");


 $(document).scroll(function(){ // detect scrolling

     var scrollWindowPos = $(document).scrollTop(); // store how far we have scrolled

     if(scrollWindowPos >= origDocHeight ) { // if we scrolled further then the original doc height
         $(document).scrollTop(0); // then scroll to the top
     }       
 });

});

0 个答案:

没有答案