From f1d2fdeec84c46babd3eb1fa2ddd2c7b4d1cf2c6 Mon Sep 17 00:00:00 2001 From: Antoan Angelov Date: Wed, 27 Dec 2023 00:07:04 +0200 Subject: [PATCH] Fix bug where page is -1 when loading a second PDF --- src/View.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/View.ts b/src/View.ts index 17ab365..f3e3718 100644 --- a/src/View.ts +++ b/src/View.ts @@ -128,7 +128,9 @@ export class View { } }); - scrollEvent(currentScrollPage); + if (currentScrollPage != -1) { + scrollEvent(currentScrollPage); + } } ); } @@ -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 =