Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential fix for wrong page being displayed sometimes. #914

Merged
merged 4 commits into from
Jun 5, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Potential fix for wrong page.
  • Loading branch information
Tushar Dudani authored and Tushar Dudani committed Feb 10, 2019
commit e323b9d879345311f27f3a36a8d72f273c925101
12 changes: 12 additions & 0 deletions src/epubcfi.js
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,18 @@ class EpubCFI {
missed = this.fixMiss(startSteps, start.terminal.offset, doc, needsIgnoring ? ignoreClass : null);
range.setStart(missed.container, missed.offset);
}
try {
if (!endContainer) {
// If the end for the range is not set, it results in collapsed becoming
// true. This in turn leads to inconsistent behaviour when calling
// getBoundingRect. Wrong bounds lead to the wrong page being displayed.
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/15684911/
range.setEnd(startContainer, range.startContainer.textContent.length);
}
} catch (e) {
console.error("setting end offset to start container length failed", e);
}

} else {
console.log("No startContainer found for", this.toString());
// No start found
Expand Down