Permalink
Browse files

Code cleanup.

  • Loading branch information...
fredwu committed Jan 8, 2011
1 parent d3f5c45 commit 7e23d377a05fb8b736690bec0ea759854d2710db
Showing with 28 additions and 41 deletions.
  1. +28 −41 js/jquery.endless-scroll.js
@@ -77,63 +77,50 @@
{
$(this).scroll(function() {
if (this == document) {
- var is_scrollable = $(document).height() - $(window).height() <= $(window).scrollTop() + options.bottomPixels
+ var is_scrollable = $(document).height() - $(window).height() <= $(window).scrollTop() + options.bottomPixels;
} else {
// calculates the actual height of the scrolling container
var inner_wrap = $(".endless_scroll_inner_wrap", this);
if (inner_wrap.length == 0) {
$(this).wrapInner("<div class=\"endless_scroll_inner_wrap\" />");
}
var is_scrollable = inner_wrap.length > 0 &&
- (inner_wrap.height() - $(this).height() <= $(this).scrollTop() + options.bottomPixels)
+ (inner_wrap.height() - $(this).height() <= $(this).scrollTop() + options.bottomPixels);
}
- if (is_scrollable) {
- if ((options.fireOnce == false || (options.fireOnce == true && fired != true)))
- {
- if(options.resetCounter.apply(this) === true)
- {
- fireSequence = 0;
- }
+ if (is_scrollable && (options.fireOnce == false || (options.fireOnce == true && fired != true)))
+ {
+ if (options.resetCounter.apply(this) === true) fireSequence = 0;
- fired = true;
- fireSequence++;
+ fired = true;
+ fireSequence++;
- $(options.insertAfter).after("<div id=\"endless_scroll_loader\">" + options.loader + "</div>");
+ $(options.insertAfter).after("<div id=\"endless_scroll_loader\">" + options.loader + "</div>");
- if (typeof options.data == 'function')
+ data = typeof options.data == 'function' ? options.data.apply(this) : options.data;
+ if (data !== false)
+ {
+ $("div#endless_scroll_loader").remove();
+ $(options.insertAfter).after("<div id=\"endless_scroll_data\">" + data + "</div>");
+ $("div#endless_scroll_data").hide().fadeIn();
+ $("div#endless_scroll_data").removeAttr("id");
+
+ var args = new Array();
+ args[0] = fireSequence;
+ options.callback.apply(this, args);
+
+ if (options.fireDelay !== false || options.fireDelay !== 0)
{
- data = options.data.apply(this);
+ // slight delay for preventing event firing twice
+ $("body").after("<div id=\"endless_scroll_marker\"></div>");
+ $("div#endless_scroll_marker").fadeTo(options.fireDelay, 1, function(){
+ $(this).remove();
+ fired = false;
+ });
}
else
{
- data = options.data;
- }
-
- if (data !== false)
- {
- $("div#endless_scroll_loader").remove();
- $(options.insertAfter).after("<div id=\"endless_scroll_data\">" + data + "</div>");
- $("div#endless_scroll_data").hide().fadeIn();
- $("div#endless_scroll_data").removeAttr("id");
-
- var args = new Array();
- args[0] = fireSequence;
- options.callback.apply(this, args);
-
- if (options.fireDelay !== false || options.fireDelay !== 0)
- {
- // slight delay for preventing event firing twice
- $("body").after("<div id=\"endless_scroll_marker\"></div>");
- $("div#endless_scroll_marker").fadeTo(options.fireDelay, 1, function(){
- $(this).remove();
- fired = false;
- });
- }
- else
- {
- fired = false;
- }
+ fired = false;
}
}
}

0 comments on commit 7e23d37

Please sign in to comment.