From f5dc0f78fd18f0abb0a3d8514229b48fa01dcaf6 Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Mon, 29 Apr 2024 16:57:49 -0400 Subject: [PATCH] stub pagination more --- src/routes/documents/[id]-[slug]/+page.svelte | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/routes/documents/[id]-[slug]/+page.svelte b/src/routes/documents/[id]-[slug]/+page.svelte index dc9a2666b..2910aa3f8 100644 --- a/src/routes/documents/[id]-[slug]/+page.svelte +++ b/src/routes/documents/[id]-[slug]/+page.svelte @@ -35,8 +35,19 @@ goto(u); } + // pagination + function next() { + currentPage = Math.min(currentPage + 1, document.page_count); + } + + function previous() { + currentPage = Math.max(currentPage - 1, 1); + } + // scroll to a page - function scrollToPage(n: number) {} + function scrollToPage(n: number) { + currentPage = n; + } @@ -65,10 +76,14 @@ scrollToPage(e.detail)} + on:next={next} + on:previous={previous} + bind:page={currentPage} totalPages={document.page_count} + has_next={currentPage < document.page_count} + has_previous={currentPage > 1} />