diff --git a/UI/Web/src/app/book-reader/book-reader/book-reader.component.html b/UI/Web/src/app/book-reader/book-reader/book-reader.component.html index 844480c31..563db7232 100644 --- a/UI/Web/src/app/book-reader/book-reader/book-reader.component.html +++ b/UI/Web/src/app/book-reader/book-reader/book-reader.component.html @@ -1,4 +1,4 @@ -
+
Skip to main content @@ -53,7 +53,7 @@ (clickToPaginateChanged)="showPaginationOverlay($event)" (fullscreen)="toggleFullscreen()" (layoutModeUpdate)="updateLayoutMode($event)" - (readingDirection)="readingDirection = $event" + (readingDirection)="updateReadingDirection($event)" (immersiveMode)="immersiveMode = $event" > @@ -73,17 +73,19 @@
+
-
+
- -
-
-
+ +
+
+
-
- +
+ +
diff --git a/UI/Web/src/app/book-reader/book-reader/book-reader.component.scss b/UI/Web/src/app/book-reader/book-reader/book-reader.component.scss index 37b9a3af0..ca3fa5ccb 100644 --- a/UI/Web/src/app/book-reader/book-reader/book-reader.component.scss +++ b/UI/Web/src/app/book-reader/book-reader/book-reader.component.scss @@ -44,6 +44,7 @@ $dark-form-background-no-opacity: rgb(1, 4, 9); $primary-color: #0062cc; +$action-bar-height: 38px; // Drawer @@ -92,8 +93,8 @@ $primary-color: #0062cc; background-color: var(--br-actionbar-bg-color); overflow: hidden; box-shadow: 0 0 6px 0 rgb(0 0 0 / 70%); - max-height: 38px; - height: 38px; + max-height: $action-bar-height; + height: $action-bar-height; .book-title-text { text-align: center; @@ -122,26 +123,62 @@ $primary-color: #0062cc; } } - - -.reading-section { - max-height: 100vh; - width: 100%; - //overflow: auto; // This will break progress reporting - height: calc(var(--vh, 1vh) * 100); - padding-top: 38px; -} - .reader-container { outline: none; // Only the reading section itself shouldn't receive any outline. We use it to shift focus in fullscreen mode overflow: auto; + height: calc(var(--vh, 1vh) * 100); + position: relative; + + &.column-layout-1 { + height: calc(var(--vh) * 100); + } + + &.column-layout-2 { + height: calc(var(--vh) * 100); + } +} + +.reading-section { + width: 100%; + //overflow: auto; // This will break progress reporting + height: 100vh; + padding-top: $action-bar-height; + position: relative; + + &.column-layout-1 { + height: calc((var(--vh, 1vh) * 100) - $action-bar-height); + } + + &.column-layout-2 { + height: calc((var(--vh, 1vh) * 100) - $action-bar-height); + } +} + +.book-container { + position: relative; + height: 100%; + + &.column-layout-1 { + height: calc((var(--vh, 1vh) * 100) - $action-bar-height); + } + + &.column-layout-2 { + height: calc((var(--vh, 1vh) * 100) - $action-bar-height); + } } .book-content { position: relative; padding: 20px 0; margin: 0px 0px; - height: calc(var(--vh, 1vh) * 100); // This will ensure bottom bar extends to the bottom of the screen + + &.column-layout-1 { + height: calc((var(--vh) * 100) - calc($action-bar-height * 2)); + } + + &.column-layout-2 { + height: calc((var(--vh) * 100) - calc($action-bar-height * 2)); + } a, :link { color: var(--brtheme-link-text-color); @@ -238,7 +275,7 @@ $primary-color: #0062cc; cursor: pointer; opacity: 0; background: transparent; - padding-top: 38px; + padding-top: $action-bar-height; } // This class pushes the click area to the left a bit to let users click the scrollbar @@ -252,7 +289,7 @@ $primary-color: #0062cc; cursor: pointer; opacity: 0; background: transparent; - padding-top: 38px; + padding-top: $action-bar-height; } .left { @@ -265,7 +302,7 @@ $primary-color: #0062cc; cursor: pointer; opacity: 0; background: transparent; - padding-top: 38px; + padding-top: $action-bar-height; } .highlight { diff --git a/UI/Web/src/app/book-reader/book-reader/book-reader.component.ts b/UI/Web/src/app/book-reader/book-reader/book-reader.component.ts index 28228f288..0fa3fc24e 100644 --- a/UI/Web/src/app/book-reader/book-reader/book-reader.component.ts +++ b/UI/Web/src/app/book-reader/book-reader/book-reader.component.ts @@ -524,8 +524,9 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { this.libraryType = type; }); - this.updateLayoutMode(this.user.preferences.bookReaderLayoutMode || BookPageLayoutMode.Default); - + // We need to think about if the user modified this and this function call is a continuous reader one + //this.updateLayoutMode(this.user.preferences.bookReaderLayoutMode || BookPageLayoutMode.Default); + this.updateImagesWithHeight(); if (this.pageNum >= this.maxPages) { @@ -586,9 +587,9 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { @HostListener('window:keydown', ['$event']) handleKeyPress(event: KeyboardEvent) { if (event.key === KEY_CODES.RIGHT_ARROW) { - this.nextPage(); + this.movePage(this.readingDirection === ReadingDirection.LeftToRight ? PAGING_DIRECTION.FORWARD : PAGING_DIRECTION.BACKWARDS); } else if (event.key === KEY_CODES.LEFT_ARROW) { - this.prevPage(); + this.movePage(this.readingDirection === ReadingDirection.LeftToRight ? PAGING_DIRECTION.BACKWARDS : PAGING_DIRECTION.FORWARD); } else if (event.key === KEY_CODES.ESC_KEY) { this.closeReader(); } else if (event.key === KEY_CODES.SPACE) { @@ -791,7 +792,8 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { * Applies a max-height inline css property on each image in the page if the layout mode is column-based, else it removes the property */ updateImagesWithHeight() { - const images = this.readingSectionElemRef.nativeElement.querySelectorAll('img') || []; + + const images = this.readingSectionElemRef?.nativeElement.querySelectorAll('img') || []; if (this.layoutMode !== BookPageLayoutMode.Default) { const height = this.ColumnHeight; @@ -807,7 +809,7 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { setupPage(part?: string | undefined, scrollTop?: number | undefined) { this.isLoading = false; - this.scrollbarNeeded = this.readingHtml.nativeElement.clientHeight > this.readingSectionElemRef.nativeElement.clientHeight; + this.scrollbarNeeded = this.readingHtml.nativeElement.clientHeight > this.reader.nativeElement.clientHeight; // Virtual Paging stuff this.updateWidthAndHeightCalcs(); @@ -877,6 +879,10 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { } } + /** + * Given a direction, calls the next or prev page method + * @param direction Direction to move + */ movePage(direction: PAGING_DIRECTION) { if (direction === PAGING_DIRECTION.BACKWARDS) { this.prevPage(); @@ -896,7 +902,6 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { const [currentVirtualPage, _, pageWidth] = this.getVirtualPage(); if (currentVirtualPage > 1) { - // -2 apparently goes back 1 virtual page... this.scrollService.scrollToX((currentVirtualPage - 2) * pageWidth, this.readingHtml.nativeElement); this.handleScrollEvent(); @@ -904,11 +909,7 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { } } - if (this.readingDirection === ReadingDirection.LeftToRight) { - this.setPageNum(this.pageNum - 1); - } else { - this.setPageNum(this.pageNum + 1); - } + this.setPageNum(this.pageNum - 1); if (oldPageNum === 0) { // Move to next volume/chapter automatically @@ -933,7 +934,6 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { const [currentVirtualPage, totalVirtualPages, pageWidth] = this.getVirtualPage(); if (currentVirtualPage < totalVirtualPages) { - //this.scrollService.scrollToX(scrollOffset + pageWidth, this.readingHtml.nativeElement); // +0 apparently goes forward 1 virtual page... this.scrollService.scrollToX((currentVirtualPage) * pageWidth, this.readingHtml.nativeElement); this.handleScrollEvent(); @@ -949,11 +949,7 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { } - if (this.readingDirection === ReadingDirection.LeftToRight) { - this.setPageNum(this.pageNum + 1); - } else { - this.setPageNum(this.pageNum - 1); - } + this.setPageNum(this.pageNum + 1); if (oldPageNum === this.pageNum) { return; } @@ -982,23 +978,8 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { const scrollOffset = this.readingHtml.nativeElement.scrollLeft; const totalScroll = this.readingHtml.nativeElement.scrollWidth; const pageWidth = this.getPageWidth(); - - // console.log('scrollOffset: ', scrollOffset); - // console.log('totalScroll: ', totalScroll); - // console.log('page width: ', pageWidth); - // console.log('delta: ', totalScroll - scrollOffset) - - // // If everything fits on a single page - // if (totalScroll - pageWidth === 0) { - // return [1, 1, pageWidth]; - // } - - // // totalVirtualPages needs to be -1 because we can't scroll to totalOffset only on page 2 - - // const currentVirtualPage = Math.max(1, (scrollOffset === 0) ? 1 : Math.round(scrollOffset / pageWidth)); - const delta = totalScroll - scrollOffset; - //let totalVirtualPages = Math.max(1, Math.round((totalScroll - pageWidth) / pageWidth)); + const totalVirtualPages = Math.max(1, Math.round((totalScroll) / pageWidth)); let currentVirtualPage = 1; @@ -1014,8 +995,6 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { currentVirtualPage = Math.min(Math.max(1, Math.round((scrollOffset + pageWidth) / pageWidth)), totalVirtualPages); } - console.log('currentPage: ', currentVirtualPage , ' totalPage: ', totalVirtualPages); - return [currentVirtualPage, totalVirtualPages, pageWidth]; } @@ -1205,6 +1184,10 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { this.updateImagesWithHeight(); } + updateReadingDirection(readingDirection: ReadingDirection) { + this.readingDirection = readingDirection; + } + // Table of Contents cleanIdSelector(id: string) { const tokens = id.split('/'); diff --git a/UI/Web/src/app/manga-reader/manga-reader.component.html b/UI/Web/src/app/manga-reader/manga-reader.component.html index 30a364d6c..f48534958 100644 --- a/UI/Web/src/app/manga-reader/manga-reader.component.html +++ b/UI/Web/src/app/manga-reader/manga-reader.component.html @@ -38,7 +38,7 @@ ondragstart="return false;" onselectstart="return false;">
-
- +   This will hide the menu behind a click on the reader document and turn tap to paginate on This will hide the menu behind a click on the reader document and turn tap to paginate on