EPUB CSS Parsing Issues (#690)
* WIP. Rewrote some of the Regex to better support css escaping. We now escape background-image, border-image, and list-style-image within css files. * Added position relative to help with positioning on books that are just absolute positioned elements. * When there is absolute positioning, like in some epub based comics, supress the bottom action bar since it wont render in the correct location. * Fixed tests * Commented out tests
This commit is contained in:
parent
22497645a9
commit
60dd66f6ae
6 changed files with 81 additions and 8 deletions
|
@ -111,6 +111,9 @@
|
|||
<ng-container [ngTemplateOutlet]="actionBar"></ng-container>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div *ngIf="page !== undefined && scrollbarNeeded">
|
||||
<ng-container [ngTemplateOutlet]="actionBar"></ng-container>
|
||||
</div> -->
|
||||
|
||||
<ng-template #actionBar>
|
||||
<div class="reading-bar row no-gutters justify-content-between">
|
||||
|
|
|
@ -155,6 +155,11 @@ $primary-color: #0062cc;
|
|||
|
||||
.reading-section {
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.book-content {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.drawer-body {
|
||||
|
|
|
@ -160,7 +160,11 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||
readerStyles: string = '';
|
||||
darkModeStyleElem!: HTMLElement;
|
||||
topOffset: number = 0; // Offset for drawer and rendering canvas
|
||||
scrollbarNeeded = false; // Used for showing/hiding bottom action bar
|
||||
/**
|
||||
* Used for showing/hiding bottom action bar. Calculates if there is enough scroll to show it.
|
||||
* Will hide if all content in book is absolute positioned
|
||||
*/
|
||||
scrollbarNeeded = false;
|
||||
readingDirection: ReadingDirection = ReadingDirection.LeftToRight;
|
||||
|
||||
private readonly onDestroy = new Subject<void>();
|
||||
|
@ -715,6 +719,14 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||
this.isLoading = false;
|
||||
this.scrollbarNeeded = this.readingSectionElemRef.nativeElement.scrollHeight > this.readingSectionElemRef.nativeElement.clientHeight;
|
||||
|
||||
const itemsOnScreen = Array.from(this.readingHtml.nativeElement.querySelectorAll('*')).filter(elem => (elem as HTMLElement).nodeName != 'STYLE');
|
||||
const itemsWithAbsolutePositioning = itemsOnScreen.filter(elem => (elem as HTMLElement).style.getPropertyValue('position') === 'absolute').length;
|
||||
|
||||
if (itemsWithAbsolutePositioning >= itemsOnScreen.length) {
|
||||
// Supress bottom actionbar. This is because of how the html is structured, with abs positioning, it will render inside images, etc.
|
||||
this.scrollbarNeeded = false;
|
||||
}
|
||||
|
||||
// Find all the part ids and their top offset
|
||||
this.setupPageAnchors();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue