fix: scrolling to top when changing pages

This commit is contained in:
Spectralitree 2021-12-21 00:21:18 +01:00
parent af9380365d
commit 8a359ae310

View File

@ -8,7 +8,7 @@ export let pageAmount: number;
<Pagination class="mx-auto" arialabel="member list page navigation"> <Pagination class="mx-auto" arialabel="member list page navigation">
{#if currentPage !== 1} {#if currentPage !== 1}
<PaginationItem> <PaginationItem>
<PaginationLink href="#" previous on:click={() => currentPage -= 1}></PaginationLink> <PaginationLink href="#" previous on:click={(e) => {e.preventDefault(); currentPage -= 1}}></PaginationLink>
</PaginationItem> </PaginationItem>
{:else} {:else}
<PaginationItem disabled> <PaginationItem disabled>
@ -17,12 +17,12 @@ export let pageAmount: number;
{/if} {/if}
{#if currentPage > 2} {#if currentPage > 2}
<PaginationItem> <PaginationItem>
<PaginationLink href="#" on:click={() => currentPage = 1}>1</PaginationLink> <PaginationLink href="#" on:click={(e) => {e.preventDefault(); currentPage = 1}}>1</PaginationLink>
</PaginationItem> </PaginationItem>
{/if} {/if}
{#if currentPage === 4} {#if currentPage === 4}
<PaginationItem> <PaginationItem>
<PaginationLink href="#" on:click={() => currentPage = 2}>2</PaginationLink> <PaginationLink href="#" on:click={(e) => {e.preventDefault(); currentPage = 2}}>2</PaginationLink>
</PaginationItem> </PaginationItem>
{/if} {/if}
{#if currentPage > 4} {#if currentPage > 4}
@ -32,7 +32,7 @@ export let pageAmount: number;
{/if} {/if}
{#if currentPage > 1} {#if currentPage > 1}
<PaginationItem> <PaginationItem>
<PaginationLink href="#" on:click={() => currentPage -= 1}>{currentPage - 1}</PaginationLink> <PaginationLink href="#" on:click={(e) => {e.preventDefault(); currentPage -= 1}}>{currentPage - 1}</PaginationLink>
</PaginationItem> </PaginationItem>
{/if} {/if}
<PaginationItem active> <PaginationItem active>
@ -40,7 +40,7 @@ export let pageAmount: number;
</PaginationItem> </PaginationItem>
{#if currentPage < pageAmount} {#if currentPage < pageAmount}
<PaginationItem> <PaginationItem>
<PaginationLink href="#" on:click={() => currentPage += 1}>{currentPage + 1}</PaginationLink> <PaginationLink href="#" on:click={(e) => {e.preventDefault(); currentPage += 1}}>{currentPage + 1}</PaginationLink>
</PaginationItem> </PaginationItem>
{/if} {/if}
{#if currentPage < pageAmount - 3} {#if currentPage < pageAmount - 3}
@ -50,17 +50,17 @@ export let pageAmount: number;
{/if} {/if}
{#if currentPage === pageAmount - 3} {#if currentPage === pageAmount - 3}
<PaginationItem> <PaginationItem>
<PaginationLink href="#" on:click={() => currentPage = pageAmount - 1}>{pageAmount - 1}</PaginationLink> <PaginationLink href="#" on:click={(e) => {e.preventDefault(); currentPage = pageAmount - 1}}>{pageAmount - 1}</PaginationLink>
</PaginationItem> </PaginationItem>
{/if} {/if}
{#if currentPage < pageAmount - 1} {#if currentPage < pageAmount - 1}
<PaginationItem> <PaginationItem>
<PaginationLink href="#" on:click={() => currentPage = pageAmount}>{pageAmount}</PaginationLink> <PaginationLink href="#" on:click={(e) => { e.preventDefault(); currentPage = pageAmount}}>{pageAmount}</PaginationLink>
</PaginationItem> </PaginationItem>
{/if} {/if}
{#if currentPage !== pageAmount} {#if currentPage !== pageAmount}
<PaginationItem> <PaginationItem>
<PaginationLink href="#" next on:click={() => currentPage += 1}></PaginationLink> <PaginationLink href="#" next on:click={(e) => {e.preventDefault(); currentPage += 1}}></PaginationLink>
</PaginationItem> </PaginationItem>
{:else} {:else}
<PaginationItem disabled> <PaginationItem disabled>
@ -68,3 +68,4 @@ export let pageAmount: number;
</PaginationItem> </PaginationItem>
{/if} {/if}
</Pagination> </Pagination>
{/if}