Skip to content

Commit

Permalink
EPUB: PageMapping: Accept any AbstractRange in methods
Browse files Browse the repository at this point in the history
  • Loading branch information
AbeJellinek committed Sep 4, 2024
1 parent 96eaa7b commit f228509
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/dom/common/lib/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class PersistentRange {

endOffset: number;

constructor(range: Range) {
constructor(range: AbstractRange) {
this.startContainer = range.startContainer;
this.startOffset = range.startOffset;
this.endContainer = range.endContainer;
Expand Down
4 changes: 2 additions & 2 deletions src/dom/epub/lib/page-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ class PageMapping {
((new Date().getTime() - startTime) / 1000).toFixed(2)}s`);
}

getPageIndex(range: Range): number | null {
getPageIndex(range: AbstractRange): number | null {
let pageStartRange = this.tree.getPairOrNextLower(new PersistentRange(range))?.[0];
if (!pageStartRange) {
return null;
}
return this.tree.keysArray().indexOf(pageStartRange);
}

getPageLabel(range: Range): string | null {
getPageLabel(range: AbstractRange): string | null {
return this.tree.getPairOrNextLower(new PersistentRange(range))?.[1] ?? null;
}

Expand Down

0 comments on commit f228509

Please sign in to comment.