Jordan Plahn
Jordan Plahn

Reputation: 375

Infinite scroll with no content

Maybe this is just me thinking of a way to create a really obnoxious "Site under construction" page, but is there anyway to create an infinite scroll when you don't actually have any content? So essentially, you would just scroll down a white page forever?

Would it work to simply use two page and constantly "refetch" the other page each time you approach the bottom of the one you're currently on? This might be a terrible idea from the memory standpoint of the browser, but I thought with only two pages that may not be an issue.

Upvotes: 1

Views: 252

Answers (1)

Seder
Seder

Reputation: 2763

I don't know why you will need such thing but you can increase the height while scrolling by the amount you scrolled or such thing

var windowHeight = $(window).height(); 
var oldScrollTop = 0 ; 

$(document).ready(function(){
    $('body').height(windowHeight+50); 
})

$(window).scroll(function(){
    var scrollTop = $(this).scrollTop(); 
var newHeight = windowHeight + scrollTop; 
    if(scrollTop > oldScrollTop)
    {
        oldScrollTop = scrollTop; 
        $('body').height(newHeight); 
    }
}); 

Check this fiddle out http://jsfiddle.net/Lx563/

Upvotes: 2

Related Questions