I'm looking for a way to continuously duplicate the contents of a div as I scroll, creating the illusion of an infinitely scrolling page. My current markup looks like this and you can also find a working example in this fiddle https://jsfiddle.net/guht49La/:
var inserted = false
$(window).scroll(function() {
var scroll = $(window).scrollTop();
if (scroll >= 800 && !inserted) {
var $button = $('.hd').clone();
($button).insertBefore('.ap');
inserted = true;
} else {
}
});
While this code only inserts it once, I am aiming to have it continue inserting every 800px (for instance) to create the continuous scrolling effect. Any suggestions on how to achieve this would be highly appreciated!