forked from metafizzy/infinite-scroll
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request metafizzy#106 from ryleyb/master
Add a local mode
- Loading branch information
Showing
2 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Calculate internal height (used for local scroll) | ||
// this function is from the old localMode I think? | ||
function infsrc_local_hiddenHeight(element) { | ||
var height = 0; | ||
$(element).children().each(function() { | ||
height = height + $(this).outerHeight(false); | ||
}); | ||
return height; | ||
} | ||
|
||
$.extend($.infinitescroll.prototype,{ | ||
_nearbottom_local: function infscr_nearbottom_local() { | ||
var opts = this.options, instance = this, | ||
pixelsFromWindowBottomToBottom = infsrc_local_hiddenHeight(opts.binder) | ||
- $(opts.binder).scrollTop() - $(opts.binder).height(); | ||
|
||
if (opts.local_pixelsFromNavToBottom == undefined){ | ||
opts.local_pixelsFromNavToBottom = infsrc_local_hiddenHeight(opts.binder) + | ||
$(opts.binder).offset().top - $(opts.navSelector).offset().top; | ||
} | ||
instance._debug('local math:', pixelsFromWindowBottomToBottom, | ||
opts.local_pixelsFromNavToBottom); | ||
|
||
return (pixelsFromWindowBottomToBottom - opts.bufferPx < opts.local_pixelsFromNavToBottom); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters