Skip to content

Commit

Permalink
Added infinite scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jul 22, 2011
1 parent 2a1455e commit a64ac6e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/http/public/javascripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,29 @@ function init(state) {
};
}

/**
* Infinite scroll.
*/

function infiniteScroll() {
if (infiniteScroll.bound) return;
var body = o('body');
infiniteScroll.bound = true;

o(window).scroll(function(e){
var top = body.scrollTop()
, height = body.innerHeight()
, windowHeight = window.innerHeight
, pad = 30;

if (top + windowHeight + pad >= height) {
to += more;
infiniteScroll.bound = false;
o(window).unbind('scroll');
}
});
}

/**
* Show jobs with `state`.
*
Expand Down Expand Up @@ -124,6 +147,8 @@ function refreshJobs(state, fn) {
+ state + '/0..' + to
+ '/' + sort;

infiniteScroll();

request(url, function(jobs){
var len = jobs.length
, job
Expand Down

0 comments on commit a64ac6e

Please sign in to comment.