Skip to content

Commit

Permalink
fix(TransactionsGrid): improve pagination scrolling behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhthomas committed Mar 12, 2024
1 parent 5c1db56 commit a9696a2
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/lib/components/transactions/TransactionsGrid.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@
export let initialTransactions: TransactionArray;
$: currentPage = tryParseInt($page.url.searchParams.get('page')) ?? 1;
$: currentPage,
tick().then(() =>
document.querySelector('main.main')?.scrollTo({
behavior: 'smooth',
top:
(document.querySelector<HTMLDivElement>('#transactionsGrid')?.offsetTop ??
120) - 120
})
);
const scrollTop = async () => {
await tick();
await tick();
document.querySelector('main.main')?.scrollTo({
behavior: 'smooth',
top:
(document.querySelector<HTMLDivElement>('#transactionsGrid')?.offsetTop ??
120) - 120
});
};
let preferences = usePreferencesStore();
Expand Down Expand Up @@ -131,6 +133,7 @@
const url = new URL($page.url);
url.searchParams.set('page', newPage.toString());
goto(url);
scrollTop();
};
</script>

Expand All @@ -144,6 +147,7 @@
{pages}
on:previous={() => updatePage(-1)}
on:next={() => updatePage(1)}
on:click={() => scrollTop()}
/>
</div>
{/if}
Expand Down

0 comments on commit a9696a2

Please sign in to comment.