accounts: fix infinite scroll over-loading, use scrollend+polyfill

calculation for number of rows to be drawn was wrong, fixed now. To
compensate for overshooting with fast scrolling, speed is calculated
using previous scrollY in rows/scroll, and used to render more rows.
Also, the "scrollend" event is used to load more at the end of a scroll
always. Since this isn't available on safari/webkit(2gtk), a polyfill
has been added.
This commit is contained in:
Harvey Tindall
2025-05-26 21:52:31 +01:00
parent ac56ad1400
commit 4dcec4b9c7
6 changed files with 82 additions and 26 deletions
+7 -4
View File
@@ -127,7 +127,7 @@ let isInviteURL = window.invites.isInviteURL();
let isAccountURL = accounts.isAccountURL();
// load tabs
const tabs: { id: string, url: string, reloader: () => void }[] = [
const tabs: { id: string, url: string, reloader: () => void, unloader?: () => void }[] = [
{
id: "invites",
url: "",
@@ -148,16 +148,19 @@ const tabs: { id: string, url: string, reloader: () => void }[] = [
// Don't keep loading the same item on every tab refresh
isAccountURL = false;
}
window.onscroll = accounts.detectScroll;
accounts.bindPageEvents();
}),
unloader: accounts.unbindPageEvents
},
{
id: "activity",
url: "activity",
reloader: () => {
activity.reload()
window.onscroll = activity.detectScroll;
activity.bindPageEvents();
},
unloader: activity.unbindPageEvents
},
{
id: "settings",
@@ -171,7 +174,7 @@ const defaultTab = tabs[0];
window.tabs = new Tabs();
for (let tab of tabs) {
window.tabs.addTab(tab.id, window.pages.Admin + "/" + tab.url, null, tab.reloader);
window.tabs.addTab(tab.id, window.pages.Admin + "/" + tab.url, null, tab.reloader, tab.unloader || null);
}
let matchedTab = false