continue to auto-load content while the window is not scrollable
This commit is contained in:
parent
283bca3a2e
commit
8d39770680
|
@ -20,10 +20,17 @@
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
url: $('.content_list').data('href') || window.location.href,
|
url: $('.content_list').data('href') || window.location.href,
|
||||||
data: `limit=${this.limit}&offset=${this.offset}`,
|
data: `limit=${this.limit}&offset=${this.offset}`,
|
||||||
complete: () => this.loading.hide(),
|
error: () => this.loading.hide(),
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
Pager.append(data.count, data.html);
|
this.append(data.count, data.html);
|
||||||
Pager.callback();
|
this.callback();
|
||||||
|
|
||||||
|
// keep loading until we've filled the viewport height
|
||||||
|
if (!this.isScrollable()) {
|
||||||
|
this.getOld();
|
||||||
|
} else {
|
||||||
|
this.loading.hide();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
});
|
});
|
||||||
|
@ -38,17 +45,21 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isScrollable() {
|
||||||
|
return $(document).height() > $(window).height() + $(window).scrollTop() + 400;
|
||||||
|
},
|
||||||
|
|
||||||
initLoadMore() {
|
initLoadMore() {
|
||||||
$(document).unbind('scroll');
|
$(document).unbind('scroll');
|
||||||
$(document).endlessScroll({
|
$(document).endlessScroll({
|
||||||
bottomPixels: 400,
|
bottomPixels: 400,
|
||||||
fireDelay: 1000,
|
fireDelay: 1000,
|
||||||
fireOnce: true,
|
fireOnce: true,
|
||||||
ceaseFire: () => Pager.disable !== true,
|
ceaseFire: () => this.disable === true,
|
||||||
callback: () => {
|
callback: () => {
|
||||||
if (!this.loading.is(':visible')) {
|
if (!this.loading.is(':visible')) {
|
||||||
this.loading.show();
|
this.loading.show();
|
||||||
Pager.getOld();
|
this.getOld();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue