summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorGareth Parker <blackfireweb@gmail.com>2018-06-08 22:48:26 +0100
committerGitHub <noreply@github.com>2018-06-08 22:48:26 +0100
commit0cc5566886f34f781072c1b0ae9ce85a12295a7e (patch)
treee4b6cd8e545a645cabab76bb1f8eb837c20aaaa2 /ext
parentf0e9716aa5e763480cf6accceefcea4fa73bc149 (diff)
Fixes for imposter element and range y position
Hides the imposter element once we've finished using it and checks the y position for the range against the point given
Diffstat (limited to 'ext')
-rw-r--r--ext/fg/js/document.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js
index 821a279f..9366832e 100644
--- a/ext/fg/js/document.js
+++ b/ext/fg/js/document.js
@@ -55,6 +55,8 @@ function docImposterCreate(element) {
document.body.appendChild(imposter);
imposter.scrollTop = element.scrollTop;
imposter.scrollLeft = element.scrollLeft;
+
+ return imposter;
}
function docImposterDestroy() {
@@ -65,11 +67,12 @@ function docImposterDestroy() {
function docRangeFromPoint(point) {
const element = document.elementFromPoint(point.x, point.y);
+ let imposter = null;
if (element) {
if (element.nodeName === 'IMG' || element.nodeName === 'BUTTON') {
return new TextSourceElement(element);
} else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
- docImposterCreate(element);
+ imposter = docImposterCreate(element);
}
}
@@ -86,6 +89,14 @@ function docRangeFromPoint(point) {
}
const range = document.caretRangeFromPoint(point.x, point.y);
+
+ if(imposter !== null) imposter.style.zIndex = -2147483646;
+
+ const rect = range.getClientRects()[0];
+ if (point.y > rect.bottom + 2) {
+ return;
+ }
+
if (range) {
return new TextSourceRange(range);
}