Like the "Endless Document" Script (e.g. Skittles.com)

How did they do it? Did you guys see: http://www.skittles.com ? The site never ends!

+4
source share
1 answer

Well, here is one way to do this:

$(document).ready( function(){ $(window).scroll( function(){ if ($(window).scrollTop() + $(window).height() >= $(document).height()) { $('div').clone().appendTo('body'); } } ); } ); 

With props JS Fiddle demo .

Keep in mind that any interactive content that will be cloned / added / inserted dynamically will require some kind of live() or delegate() to interact with jQuery.

However, there are reservations:

  • Endless scrolling is not necessarily a pleasant navigational aid, especially if the user is likely to want to view some of the content halfway down an endless page.
  • There comes a time when the browser crashes or becomes sluggish / unresponsive due to the huge amount of content that it must support in memory.
0
source

All Articles