Skip to content

Commit

Permalink
Merge pull request metafizzy#106 from ryleyb/master
Browse files Browse the repository at this point in the history
Add a local mode
  • Loading branch information
samcleaver committed Dec 19, 2011
2 parents c97d3b9 + 0b3957f commit 6468eeb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
26 changes: 26 additions & 0 deletions behaviors/local.js
@@ -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);
}
});
3 changes: 1 addition & 2 deletions jquery.infinitescroll.js
Expand Up @@ -337,8 +337,7 @@

// if behavior is defined and this function is extended, call that instead of default
if (!!opts.behavior && this['_nearbottom_'+opts.behavior] !== undefined) {
this['_nearbottom_'+opts.behavior].call(this);
return;
return this['_nearbottom_'+opts.behavior].call(this);
}

this._debug('math:', pixelsFromWindowBottomToBottom, opts.pixelsFromNavToBottom);
Expand Down

0 comments on commit 6468eeb

Please sign in to comment.