Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Behavior for Infinite Scroll jQuery plugin: infinite scrolling doesn't begin until after a manual trigger is clicked.
/*
--------------------------------
Infinite Scroll Behavior
Simply Recipes Mobile Style
: Infinite scroll waits for a one-time manual trigger
--------------------------------
by Jesse Gardner, http://plasticmind.com
*/
$.extend($.infinitescroll.prototype,{
_setup_simplyrecipes: function infscr_setup_simplyrecipes () {
var instance = this;
var opts = this.options;
this._binding('bind');
this._numScrolls = 0; // Register a scroll counter
this.options.loading.start = function (opts) {
if(instance._numScrolls==0) { // First scroll requires manual click
$(opts.navSelector).show();
$(opts.nextSelector).bind('click', function(e) {
e.preventDefault();
$(opts.navSelector).fadeOut('fast');
opts.loading.msg.appendTo(opts.loading.selector).fadeIn('fast');
instance.beginAjax(opts);
});
} else { // Anything after that happens automatically
$(opts.navSelector).hide();
opts.loading.msg.appendTo(opts.loading.selector).show(opts.loading.speed);
instance.beginAjax(opts);
}
}
this.options.loading.finished = function() {
opts.loading.msg.fadeOut('fast');
instance._numScrolls++;
}
return false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.