Permalink
Browse files

Issue #227 Added `prefill` option to fix document smaller than window…

… issue.
  • Loading branch information...
1 parent 12acfc8 commit 3bdd26b0e802e0af93cdd0b41e31e5d46e5f3e16 @67726e 67726e committed Oct 24, 2012
Showing with 42 additions and 27 deletions.
  1. +2 −1 .gitignore
  2. +2 −1 Readme.md
  3. +13 −4 jquery.infinitescroll.js
  4. +1 −1 jquery.infinitescroll.min.js
  5. +24 −20 test/index.html
View
@@ -1,2 +1,3 @@
-
infinte-scroll.tmproj
+.idea
+
View
@@ -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
});
```
View
@@ -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",
@@ -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 = {
@@ -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);
@@ -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) {
@@ -179,6 +184,10 @@
this._setup();
+ if (opts.prefill && $(document).height() <= $(window).height()) {
+ this.scroll();
+ }
+
// Return true to indicate successful creation
return true;
},
Oops, something went wrong.

0 comments on commit 3bdd26b

Please sign in to comment.