From 7f9cfaa8ef5258dd343d01714cf97a802e2cdf30 Mon Sep 17 00:00:00 2001 From: octospacc Date: Sat, 13 Jan 2024 20:52:49 +0100 Subject: [PATCH] Fixed not-scrolling-not-loading bug for MBViewer --- public/MBViewer/js/MBViewer.js | 17 +++++++++++++++++ public/MBViewer/js/telegram-web.js | 3 +++ 2 files changed, 20 insertions(+) diff --git a/public/MBViewer/js/MBViewer.js b/public/MBViewer/js/MBViewer.js index 9065bd9..e9b5fb0 100644 --- a/public/MBViewer/js/MBViewer.js +++ b/public/MBViewer/js/MBViewer.js @@ -11,6 +11,23 @@ let MbState = {}; +// +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) { return url.split('//')[1].split('/')[0]; } diff --git a/public/MBViewer/js/telegram-web.js b/public/MBViewer/js/telegram-web.js index c528eb0..4c6c057 100644 --- a/public/MBViewer/js/telegram-web.js +++ b/public/MBViewer/js/telegram-web.js @@ -328,6 +328,9 @@ var TWeb = { //$('#BottomAnchor')[0].scrollIntoView(); $('.tgme_widget_message_wrap').last().scrollIntoView(); } + if (!IsScrollableY($('html')[0])) { + TWeb.loadMore($('.js-messages_more_wrap > a'), true); + } }, error: function(data) { var timeout = $moreEl.data('timeout') || 1000;