You are going to need a bit of javascript glue on the frontend of the website to be able to achieve this functionality.
This code (with jQuery) will insert a new paragraph item at the bottom of a div called "statuses". The statuses div is where we will store all of the items.
$(document).ready(function() {
doMouseWheel = 1;
$(".statuses").after("<p id='last'></p>");
$(window).scroll(function() {
if (!doMouseWheel)
return;
var distanceTop = $('#last').offset().top - $(window).height();
if ($(window).scrollTop() > distanceTop) {
$('#loading').show();
doMouseWheel = 0;
ajaxLoad();
}
});
})
ajaxLoad() will be called when the page is scrolled down far enough.
function ajaxLoad() {
if (last_id == 0) {
$('#loading').hide();
doMouseWheel = 0;
return;
}
u = "/load-requests/";
if (last_id > 0)
u = u + "?last_id=" + last_id;
$.ajax({
dataType: "json",
url: u,
success: function(j) {
last_id = j.last_id;
for (n = 0; n < j.statuses.length; ++n) {
_line = _newLine(j.statuses[n]]);
$('ul.statuses').append(_line);
}
$('.hide-load').hide();
$('#loading .message').html('Fetching more items for the timeline');
$('#loading').slideUp();
doMouseWheel = 1;
}
})
}
The /load-requests/ URL will output JSON similar to this:
{
"statuses": [{
"who": 1,
"for": "company",
"name": "ABC Computing",
"id": 2,
"status": "added a new article",
"timez": "2008-07-17T09:24:17Z",
"timep": "2 days ago",
"additional": [{
"for": "document",
"name": "Article Name",
"value": "What is the purpose of using infinite scroll timelines to show information",
"id": 42
}, {
"name": "New Topics",
"value": "information, javascript, javascript, development"
}]
},
last_id = 3
}
}
When the page is requested, it will have last_id set, which was the last seen item.
_newLine renders the line content as a <li> item added to a <ul>.
I use the following HTML:
<ul class="statuses">
</ul>
<div class="screen" id="loading">
<div class="hide-load">
<p> </p>
<p> </p>
<p> </p>
</div>
<img src="/articles/images/homepage.gif">
<h1>Please wait...</h1>
<span class="message">Generating your personalised timeline...</span>
</div>
<div class="screen" id="error">
<p> </p>
<p> </p>
<p> </p>
<div class="simplemessage error">
<img src="/articles/images/error.png" style="vertical-align: middle;">
<strong>There were issues attempting to load some or all of your feed.</strong><br />
Sadly, not everything could be loaded. Sorry about that!
</div>
</div>
Check out this jQuery plugin: http://www.infinite-scroll.com/
The code provided is based on http://www.jquery4u.com/demos/infinite-scrolling-demo5/