Skip to content

Commit

Permalink
More viewer pagination fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Feb 22, 2024
1 parent e6bd8bc commit da3b277
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/pages/viewer/controls/Paginator.svelte
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
<script>
import { doc } from "@/viewer/document.js";
import { viewer } from "@/viewer/viewer.js";
<script lang="ts">
import { doc } from "../../../viewer/document.js";
import { viewer } from "../../../viewer/viewer.js";
import Paginator from "../../../common/Paginator.svelte";
function goToPage(readablePageNumber) {
doc.jumpToPage(readablePageNumber - 1);
}
// @ts-expect-error
$: mode = doc.mode;
$: page = doc.visiblePageNumber;
$: totalPages = viewer.document.pageCount;
$: has_next = page < totalPages;
$: has_previous = page > 1;
$: {
console.log(doc.visiblePageNumber, $doc.visiblePageNumber);
function goToPage(page) {
console.log("Go to page ", page);
doc.jumpToPage(page - 1);
}
</script>

{#if $viewer.loaded && $doc.mode !== "search" && $doc.mode !== "notes" && $doc.mode !== "thumbnail"}
{#if $viewer.loaded && mode !== "search" && mode !== "notes" && mode !== "thumbnail"}
<Paginator
bind:page={$doc.visiblePageNumber}
totalPages={$viewer.document.pageCount}
{page}
{totalPages}
{has_next}
{has_previous}
on:previous={goToPage}
on:next={goToPage}
on:goTo={goToPage}
goToNav
has_next={$doc.visiblePageNumber < $viewer.document.pageCount}
has_prev={$doc.visiblePageNumber > 1}
/>
{/if}

0 comments on commit da3b277

Please sign in to comment.