Skip to content

Commit

Permalink
Fixes for viewer pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Feb 22, 2024
1 parent c4d0890 commit e6bd8bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
10 changes: 5 additions & 5 deletions src/common/Paginator.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
$: inputWidth = String(page ?? 0).length;
$: invalidValue = page > totalPages || !page;
export function previous() {
dispatch("previous");
function previous() {
dispatch("previous", page - 1);
}
export function next() {
dispatch("next");
function next() {
dispatch("next", page + 1);
}
export function goTo(page: number) {
function goTo(page: number) {
dispatch("goTo", page);
}
Expand Down
18 changes: 7 additions & 11 deletions src/pages/viewer/controls/Paginator.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,22 @@
import { viewer } from "@/viewer/viewer.js";
import Paginator from "../../../common/Paginator.svelte";
function gotoPage(readablePageNumber) {
function goToPage(readablePageNumber) {
doc.jumpToPage(readablePageNumber - 1);
}
function increment() {
gotoPage(Math.min(doc.visiblePageNumber + 1, viewer.document.pageCount));
}
function decrement() {
gotoPage(Math.max(doc.visiblePageNumber - 1, 1));
$: {
console.log(doc.visiblePageNumber, $doc.visiblePageNumber);
}
</script>

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

0 comments on commit e6bd8bc

Please sign in to comment.