Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes for work with hidden divs and multiple infilite scrolling tabs #56

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions jquery.jscroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
_$window = $(window),
_$body = $('body'),
_$scroll = _isWindow ? _$window : $e,
_nextHref = $.trim(_$next.attr('href') + ' ' + _options.contentSelector),
_nextHref = _$next.attr('href') ? $.trim(_$next.attr('href') + ' ' + _options.contentSelector) : false,
_unique_id = Math.floor((Math.random() * 10000) + 1),

// Check if a loading image is defined and preload
_preloadImage = function() {
Expand Down Expand Up @@ -78,10 +79,11 @@

// Remove the jscroll behavior and data from an element
_destroy = function() {
return _$scroll.unbind('.jscroll')
.removeData('jscroll')
.find('.jscroll-inner').children().unwrap()
.filter('.jscroll-added').children().unwrap();
_$scroll.unbind('.jscroll' + _unique_id);
$e.removeData('jscroll');
$e.find('.jscroll-inner').children().unwrap();
$e.filter('.jscroll-added').children().unwrap();
$e.find('.jscroll-loading').remove();
},

// Observe the scroll event for when to trigger the next load
Expand All @@ -96,7 +98,7 @@
innerTop = $inner.length ? $inner.offset().top : 0,
iTotalHeight = Math.ceil(iTopHeight - innerTop + _$scroll.height() + iContainerTop);

if (!data.waiting && iTotalHeight + _options.padding >= $inner.outerHeight()) {
if (!data.waiting && $inner.outerHeight() > 0 && iTotalHeight + _options.padding >= $inner.outerHeight()) {
//data.nextHref = $.trim(data.nextHref + ' ' + _options.contentSelector);
_debug('info', 'jScroll:', $inner.outerHeight() - iTotalHeight, 'from bottom. Loading next request...');
return _load();
Expand All @@ -123,15 +125,15 @@
if (_$body.height() <= _$window.height()) {
_observe();
}
_$scroll.unbind('.jscroll').bind('scroll.jscroll', function() {
_$scroll.unbind('.jscroll' + _unique_id).bind('scroll.jscroll' + _unique_id, function() {
return _observe();
});
if (_options.autoTriggerUntil > 0) {
_options.autoTriggerUntil--;
}
} else {
_$scroll.unbind('.jscroll');
$next.bind('click.jscroll', function() {
_$scroll.unbind('.jscroll' + _unique_id);
$next.bind('click.jscroll' + _unique_id, function() {
_nextWrap($next);
_load();
return false;
Expand Down Expand Up @@ -187,10 +189,11 @@
};

// Initialization
$e.data('jscroll', $.extend({}, _data, {initialized: true, waiting: false, nextHref: _nextHref}));
$e.data('jscroll', $.extend({}, _data, {initialized: true, waiting: false, nextHref: _nextHref, unique_id: _unique_id}));
_wrapInnerContent();
_preloadImage();
_setBindings();
_checkNextHref();

// Expose API methods via the jQuery.jscroll namespace, e.g. $('sel').jscroll.method()
$.extend($e.jscroll, {
Expand Down
2 changes: 1 addition & 1 deletion jquery.jscroll.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.