A collection of bug fixes (#3820)

Co-authored-by: Joseph Milazzo <joseph.v.milazzo@gmail.com>
This commit is contained in:
Fesaa 2025-06-04 09:45:10 +02:00 committed by GitHub
parent 6288d89651
commit 193e9b1da9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 268 additions and 89 deletions

View file

@ -31,9 +31,8 @@ export class TableOfContentsComponent implements OnChanges {
@Output() loadChapter: EventEmitter<{pageNum: number, part: string}> = new EventEmitter();
ngOnChanges(changes: SimpleChanges) {
console.log('Current Page: ', this.pageNum, this.currentPageAnchor);
//console.log('Current Page: ', this.pageNum, this.currentPageAnchor);
this.cdRef.markForCheck();
}
cleanIdSelector(id: string) {
@ -47,4 +46,30 @@ export class TableOfContentsComponent implements OnChanges {
loadChapterPage(pageNum: number, part: string) {
this.loadChapter.emit({pageNum, part});
}
isChapterSelected(chapterGroup: BookChapterItem) {
if (chapterGroup.page === this.pageNum) {
return true;
}
const idx = this.chapters.indexOf(chapterGroup);
if (idx < 0) {
return false; // should never happen
}
const nextIdx = idx + 1;
// Last chapter
if (nextIdx >= this.chapters.length) {
return chapterGroup.page < this.pageNum;
}
// Passed chapter, and next chapter has not been reached
const next = this.chapters[nextIdx];
return chapterGroup.page < this.pageNum && next.page > this.pageNum;
}
isAnchorSelected(chapter: BookChapterItem) {
return this.cleanIdSelector(chapter.part) === this.currentPageAnchor
}
}