Skip to content

Commit

Permalink
fix: prevent jump to table head on continuous scroll load
Browse files Browse the repository at this point in the history
  • Loading branch information
spacehamster87 committed Nov 29, 2024
1 parent 5766945 commit 5da6baf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions web/frontend/src/generic/JobList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@
let jobs = []
$: if ($initialized && $jobsStore.data) {
jobs = [...$jobsStore.data.jobs.items]
if (usePaging) {
jobs = [...$jobsStore.data.jobs.items]
} else { // Prevents jump to table head: Extends existing list instead of rendering new list
jobs = jobs.concat([...$jobsStore.data.jobs.items])
}
}
$: matchedJobs = $jobsStore.data != null ? $jobsStore.data.jobs.count : -1;
Expand Down Expand Up @@ -170,7 +174,6 @@
}
if (!usePaging) {
let scrollMultiplier = 1
window.addEventListener('scroll', () => {
let {
scrollTop,
Expand All @@ -181,8 +184,7 @@
// Add 100 px offset to trigger load earlier
if (scrollTop + clientHeight >= scrollHeight - 100 && $jobsStore.data != null && $jobsStore.data.jobs.hasNextPage) {
let pendingPaging = { ...paging }
scrollMultiplier += 1
pendingPaging.itemsPerPage = itemsPerPage * scrollMultiplier
pendingPaging.page += 1
paging = pendingPaging
};
});
Expand Down

0 comments on commit 5da6baf

Please sign in to comment.