Merge pull request #164 from toasted-nutbread/document-range-fix

Fix docRangeFromPoint sometimes not returning results
This commit is contained in:
Alex Yatskov 2019-06-26 14:17:52 -07:00 committed by GitHub
commit 672eb55a20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,19 +97,11 @@ 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) {