mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Started checking for end of word.
This commit is contained in:
parent
3a0f10195b
commit
8399af32f5
1 changed files with 18 additions and 11 deletions
|
@ -574,19 +574,26 @@ class Contents {
|
|||
|
||||
if(this.epubcfi.isCfiString(target)) {
|
||||
let range = new EpubCFI(target).toRange(this.document, ignoreClass);
|
||||
|
||||
if(range) {
|
||||
try {
|
||||
if (!range.endContainer) {
|
||||
if (!range.endContainer ||
|
||||
(range.startContainer == range.endContainer
|
||||
&& range.startOffset == range.endOffset)) {
|
||||
// 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(range.startContainer, range.startContainer.textContent.length);
|
||||
let pos = range.startContainer.textContent.indexOf(" ", range.startOffset);
|
||||
if (pos == -1) {
|
||||
pos = range.startContainer.textContent.length;
|
||||
}
|
||||
range.setEnd(range.startContainer, pos);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("setting end offset to start container length failed", e);
|
||||
}
|
||||
|
||||
if(range) {
|
||||
if (range.startContainer.nodeType === Node.ELEMENT_NODE) {
|
||||
position = range.startContainer.getBoundingClientRect();
|
||||
targetPos.left = position.left;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue