JSFiddle - React, Tailwind, and code Playground

by Brad Christie

HTML

<div id="main">

</div>

CSS

.content {
    border: 1px dotted black;
    padding: 1em;
}

JavaScript

var i = 1;

var d = function(){
    return '\
<div class="content">\
    Content '+(i++)+'\
</div>';
};

var f = function(){
    var t = $(window).scrollTop(),
        $d = $(d()).prependTo('#main');
    if (t){
        var h = $d.outerHeight();
        console.log('t:' + t + '; h:' + h);
        $(window).scrollTop(t + h);
    }
    setTimeout( f, 1000 );
};

// var f = function(){ $("#main").append(d()); setTimeout( f, 1000 ); };


f();