Skip to content

Commit

Permalink
Issue metafizzy#227 Added prefill option to fix document smaller th…
Browse files Browse the repository at this point in the history
…an window issue.
  • Loading branch information
67726e committed Oct 24, 2012
1 parent 12acfc8 commit 3bdd26b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

infinte-scroll.tmproj
.idea

3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ $('.selector').infinitescroll({
errorCallback: function () { },
infid: 0, //Instance ID
pixelsFromNavToBottom: undefined,
path: undefined
path: undefined,
prefill: false // When the document is smaller than the window, load data until the document is larger or links are exhausted
});
```

Expand Down
17 changes: 13 additions & 4 deletions jquery.infinitescroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
currPage: 1
},
debug: false,
behavior: undefined,
behavior: undefined,
binder: $(window), // used to cache the selector
nextSelector: "div.navigation a:first",
navSelector: "div.navigation",
Expand All @@ -60,8 +60,9 @@
errorCallback: function () { },
infid: 0, //Instance ID
pixelsFromNavToBottom: undefined,
path: undefined
};
path: undefined,
prefill: false // When the document is smaller than the window, load data until the document is larger or links are exhausted
};

$.infinitescroll.prototype = {

Expand Down Expand Up @@ -156,7 +157,7 @@
opts.loading.msg.fadeOut('normal');
};

// callback loading
// callback loading
opts.callback = function(instance,data) {
if (!!opts.behavior && instance['_callback_'+opts.behavior] !== undefined) {
instance['_callback_'+opts.behavior].call($(opts.contentSelector)[0], data);
Expand All @@ -165,6 +166,10 @@
if (callback) {
callback.call($(opts.contentSelector)[0], data, opts);
}

if (opts.prefill && $(document).height() <= $(window).height()) {
instance.scroll();
}
};

if (options.debug) {
Expand All @@ -179,6 +184,10 @@

this._setup();

if (opts.prefill && $(document).height() <= $(window).height()) {
this.scroll();
}

// Return true to indicate successful creation
return true;
},
Expand Down
Loading

0 comments on commit 3bdd26b

Please sign in to comment.