Skip to content
Snippets Groups Projects
Commit 08b52a0e authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

[BUGFIX] Next news not loaded if there is no scrollbar

parent a77cf4f5
No related branches found
No related tags found
No related merge requests found
...@@ -67,44 +67,50 @@ SG.ElementScrollBrowser.prototype = { ...@@ -67,44 +67,50 @@ SG.ElementScrollBrowser.prototype = {
} }
this.url = $('.tx-pagebrowse-next a').attr('href'); this.url = $('.tx-pagebrowse-next a').attr('href');
$(window).on( $(window).on('scroll', this.checkAndLoad.bind(this));
'scroll', function() {
var recordLockedOrNotInPosition = this.lock || !this.checkPosition(); // initial check
var urlIsInvalid = typeof this.url === 'undefined' || this.url === this.lastUrl; this.checkAndLoad();
if (recordLockedOrNotInPosition || urlIsInvalid) { },
return;
} /**
* Checks and loads the next page if required
this.lock = true; */
$.ajax( checkAndLoad: function() {
{ var recordLockedOrNotInPosition = this.lock || !this.checkPosition();
url: this.url, var urlIsInvalid = typeof this.url === 'undefined' || this.url === this.lastUrl;
if (recordLockedOrNotInPosition || urlIsInvalid) {
success: function(response) { return;
var results = $(response).find('.tx-sgnews-list'); }
results.each(function(index, result) {
var $result = $(result); this.lock = true;
var children = $result.children(); $.ajax(
if (!children.length) { {
return; url: this.url,
}
success: function(response) {
var $resultList = $('.tx-sgnews-list-' + $result.data('category')); var results = $(response).find('.tx-sgnews-list');
if (!$resultList.length) { results.each(function(index, result) {
$resultList = $('.tx-sgnews-list'); var $result = $(result);
} var children = $result.children();
$resultList.append(children); if (!children.length) {
return;
this.loadIndicator = $resultList.children(':last'); }
});
var $resultList = $('.tx-sgnews-list-' + $result.data('category'));
this.lastUrl = this.url; if (!$resultList.length) {
this.url = $(response).find('.tx-pagebrowse-next a').attr('href'); $resultList = $('.tx-sgnews-list');
this.lock = false; }
}.bind(this) $resultList.append(children);
}
); this.loadIndicator = $resultList.children(':last');
}.bind(this) });
this.lastUrl = this.url;
this.url = $(response).find('.tx-pagebrowse-next a').attr('href');
this.lock = false;
}.bind(this)
}
); );
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment