From 2bb166e678e73d1ff136b8c2d97c6b089372f985 Mon Sep 17 00:00:00 2001 From: CD-Z Date: Tue, 15 Aug 2023 17:38:28 +0200 Subject: [PATCH] fixed NaN error --- src/screens/reader/ReaderScreen.js | 8 +++++--- .../components/stringCreators/horizontalReaderPages.ts | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/screens/reader/ReaderScreen.js b/src/screens/reader/ReaderScreen.js index bae828c0b1..0eed7a2ef2 100644 --- a/src/screens/reader/ReaderScreen.js +++ b/src/screens/reader/ReaderScreen.js @@ -214,9 +214,11 @@ const ChapterContent = ({ route, navigation }) => { } }); useEffect(() => { - webViewRef?.current?.injectJavaScript( - `${!readerPages} && document.querySelector('chapter').style.transform = 'translate(0%)';`, - ); + if (!readerPages) { + webViewRef?.current?.injectJavaScript( + "document.querySelector('chapter').style.transform = 'translate(0%)';", + ); + } }, [readerPages]); const scrollTo = useCallback( offset => { diff --git a/src/screens/reader/components/stringCreators/horizontalReaderPages.ts b/src/screens/reader/components/stringCreators/horizontalReaderPages.ts index edf806b800..e34ebb9b38 100644 --- a/src/screens/reader/components/stringCreators/horizontalReaderPages.ts +++ b/src/screens/reader/components/stringCreators/horizontalReaderPages.ts @@ -17,10 +17,14 @@ infoBox.classList.add("hidden"); id("spacer").style.height = infoBox.scrollHeight + 'px'; const pages = (Math.ceil(textWidth / clientWidth) - 1); -page = 0; +let page = 0; + navRight.addEventListener("click", () => { page = select("chapter").getAttribute('data-page'); + if (isNaN(page)) { + page = 0; + } if (page < pages ) { page++; movePage();