diff options
author | Craig Andrews <candrews@integralblue.com> | 2009-09-19 22:53:39 -0400 |
---|---|---|
committer | Craig Andrews <candrews@integralblue.com> | 2009-09-19 22:53:39 -0400 |
commit | cf8944526ec56dd1a3522d6eced65a4d1369c321 (patch) | |
tree | f332d0390c80c70796827b12a7fde151a89f4ae6 /plugins/InfiniteScroll/jquery.infinitescroll.js | |
parent | 74296fa12c7813ad5cdc80750173c11912b5860f (diff) |
Make the infinite scroll plugin have a non-infinite scroll (button click to scroll) mode
Diffstat (limited to 'plugins/InfiniteScroll/jquery.infinitescroll.js')
-rw-r--r-- | plugins/InfiniteScroll/jquery.infinitescroll.js | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/plugins/InfiniteScroll/jquery.infinitescroll.js b/plugins/InfiniteScroll/jquery.infinitescroll.js index 670686b0e..ec31bb086 100644 --- a/plugins/InfiniteScroll/jquery.infinitescroll.js +++ b/plugins/InfiniteScroll/jquery.infinitescroll.js @@ -92,14 +92,14 @@ if (props.isDuringAjax || props.isInvalidPage || props.isDone) return; - if ( !isNearBottom(opts,props) ) return; + if ( opts.infiniteScroll && !isNearBottom(opts,props) ) return; // we dont want to fire the ajax multiple times props.isDuringAjax = true; // show the loading message and hide the previous/next links props.loadingMsg.appendTo( opts.contentSelector ).show(); - $( opts.navSelector ).hide(); + if(opts.infiniteScroll) $( opts.navSelector ).hide(); // increment the URL bit. e.g. /page/3/ props.currPage++; @@ -205,10 +205,19 @@ } }); - // bind scroll handler to element (if its a local scroll) or window - $(opts.localMode ? this : window) - .bind('scroll.infscr', function(){ infscrSetup(path,opts,props,callback); } ) - .trigger('scroll.infscr'); // trigger the event, in case it's a short page + if(opts.infiniteScroll){ + // bind scroll handler to element (if its a local scroll) or window + $(opts.localMode ? this : window) + .bind('scroll.infscr', function(){ infscrSetup(path,opts,props,callback); } ) + .trigger('scroll.infscr'); // trigger the event, in case it's a short page + }else{ + $(opts.nextSelector).click( + function(){ + infscrSetup(path,opts,props,callback); + return false; + } + ); + } return this; @@ -222,6 +231,7 @@ $.infinitescroll = { defaults : { debug : false, + infiniteScroll : true, preload : false, nextSelector : "div.navigation a:first", loadingImg : "http://www.infinite-scroll.com/loading.gif", |