Fix docRangeFromPoint sometimes not returning results
If range.getClientRects() has more than 1 result, it is possible that nothing will be returned even when hovering over a valid target.
This commit is contained in:
parent
f77ac32fe1
commit
542cdb2df9
@ -97,20 +97,12 @@ function docRangeFromPoint(point) {
|
|||||||
if(imposter !== null) imposter.style.zIndex = -2147483646;
|
if(imposter !== null) imposter.style.zIndex = -2147483646;
|
||||||
|
|
||||||
const rects = range.getClientRects();
|
const rects = range.getClientRects();
|
||||||
|
for (const rect of rects) {
|
||||||
if (rects.length === 0) {
|
if (point.y <= rect.bottom + 2) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const rect = rects[0];
|
|
||||||
if (point.y > rect.bottom + 2) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (range) {
|
|
||||||
return new TextSourceRange(range);
|
return new TextSourceRange(range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function docSentenceExtract(source, extent) {
|
function docSentenceExtract(source, extent) {
|
||||||
const quotesFwd = {'「': '」', '『': '』', "'": "'", '"': '"'};
|
const quotesFwd = {'「': '」', '『': '』', "'": "'", '"': '"'};
|
||||||
|
Loading…
Reference in New Issue
Block a user