Skip to content

Commit

Permalink
Fix bug where page is -1 when loading a second PDF
Browse files Browse the repository at this point in the history
  • Loading branch information
photown committed Dec 26, 2023
1 parent cbfac7f commit f1d2fde
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/View.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ export class View {
}
});

scrollEvent(currentScrollPage);
if (currentScrollPage != -1) {
scrollEvent(currentScrollPage);
}
}
);
}
Expand Down Expand Up @@ -426,11 +428,15 @@ export class View {
oldPage: number,
scrollToPage: boolean = true
) {
const previousPageElement = document.querySelector(
`.thumbnail-list-container:nth-child(${oldPage})`
) as HTMLElement | null;
if (previousPageElement) {
previousPageElement.classList.remove("thumbnail-list-container-selected");
if (oldPage >= 0) {
const previousPageElement = document.querySelector(
`.thumbnail-list-container:nth-child(${oldPage})`
) as HTMLElement | null;
if (previousPageElement) {
previousPageElement.classList.remove(
"thumbnail-list-container-selected"
);
}
}

(document.querySelector("#current-page") as HTMLInputElement).value =
Expand Down

0 comments on commit f1d2fde

Please sign in to comment.