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">
{#if currentPage !== 1}
<PaginationItem>
<PaginationLink href="#" previous on:click={() => currentPage -= 1}></PaginationLink>
<PaginationLink href="#" previous on:click={(e) => {e.preventDefault(); currentPage -= 1}}></PaginationLink>
</PaginationItem>
{:else}
<PaginationItem disabled>
@ -17,12 +17,12 @@ export let pageAmount: number;
{/if}
{#if currentPage > 2}
<PaginationItem>
<PaginationLink href="#" on:click={() => currentPage = 1}>1</PaginationLink>
<PaginationLink href="#" on:click={(e) => {e.preventDefault(); currentPage = 1}}>1</PaginationLink>
</PaginationItem>
{/if}
{#if currentPage === 4}
<PaginationItem>
<PaginationLink href="#" on:click={() => currentPage = 2}>2</PaginationLink>
<PaginationLink href="#" on:click={(e) => {e.preventDefault(); currentPage = 2}}>2</PaginationLink>
</PaginationItem>
{/if}
{#if currentPage > 4}
@ -32,7 +32,7 @@ export let pageAmount: number;
{/if}
{#if currentPage > 1}
<PaginationItem>
<PaginationLink href="#" on:click={() => currentPage -= 1}>{currentPage - 1}</PaginationLink>
<PaginationLink href="#" on:click={(e) => {e.preventDefault(); currentPage -= 1}}>{currentPage - 1}</PaginationLink>
</PaginationItem>
{/if}
<PaginationItem active>
@ -40,7 +40,7 @@ export let pageAmount: number;
</PaginationItem>
{#if currentPage < pageAmount}
<PaginationItem>
<PaginationLink href="#" on:click={() => currentPage += 1}>{currentPage + 1}</PaginationLink>
<PaginationLink href="#" on:click={(e) => {e.preventDefault(); currentPage += 1}}>{currentPage + 1}</PaginationLink>
</PaginationItem>
{/if}
{#if currentPage < pageAmount - 3}
@ -50,21 +50,22 @@ export let pageAmount: number;
{/if}
{#if currentPage === pageAmount - 3}
<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>
{/if}
{#if currentPage < pageAmount - 1}
<PaginationItem>
<PaginationLink href="#" on:click={() => currentPage = pageAmount}>{pageAmount}</PaginationLink>
<PaginationLink href="#" on:click={(e) => { e.preventDefault(); currentPage = pageAmount}}>{pageAmount}</PaginationLink>
</PaginationItem>
{/if}
{#if currentPage !== pageAmount}
<PaginationItem>
<PaginationLink href="#" next on:click={() => currentPage += 1}></PaginationLink>
<PaginationLink href="#" next on:click={(e) => {e.preventDefault(); currentPage += 1}}></PaginationLink>
</PaginationItem>
{:else}
<PaginationItem disabled>
<PaginationLink next></PaginationLink>
</PaginationItem>
{/if}
</Pagination>
</Pagination>
{/if}