Fixed not-scrolling-not-loading bug for MBViewer

This commit is contained in:
octospacc 2024-01-13 20:52:49 +01:00
parent da9531e616
commit 7f9cfaa8ef
2 changed files with 20 additions and 0 deletions

View File

@ -11,6 +11,23 @@
let MbState = {}; let MbState = {};
// <https://stackoverflow.com/questions/29956338/how-to-accurately-determine-if-an-element-is-scrollable/71170105#71170105>
function CanScrollEl(el, scrollAxis) {
if (0 === el[scrollAxis]) {
el[scrollAxis] = 1;
if (1 === el[scrollAxis]) {
el[scrollAxis] = 0;
return true;
}
} else {
return true;
}
return false;
}
function IsScrollableY(el) {
return (el.scrollHeight > el.clientHeight) && CanScrollEl(el, 'scrollTop') && ('hidden' !== getComputedStyle(el).overflowY);
}
function GetDomainFromUrl (url) { function GetDomainFromUrl (url) {
return url.split('//')[1].split('/')[0]; return url.split('//')[1].split('/')[0];
} }

View File

@ -328,6 +328,9 @@ var TWeb = {
//$('#BottomAnchor')[0].scrollIntoView(); //$('#BottomAnchor')[0].scrollIntoView();
$('.tgme_widget_message_wrap').last().scrollIntoView(); $('.tgme_widget_message_wrap').last().scrollIntoView();
} }
if (!IsScrollableY($('html')[0])) {
TWeb.loadMore($('.js-messages_more_wrap > a'), true);
}
}, },
error: function(data) { error: function(data) {
var timeout = $moreEl.data('timeout') || 1000; var timeout = $moreEl.data('timeout') || 1000;