aboutsummaryrefslogtreecommitdiff
path: root/ext/fg
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg')
-rw-r--r--ext/fg/css/client.css2
-rw-r--r--ext/fg/js/client.js4
-rw-r--r--ext/fg/js/popup.js4
-rw-r--r--ext/fg/js/range.js10
4 files changed, 11 insertions, 9 deletions
diff --git a/ext/fg/css/client.css b/ext/fg/css/client.css
index 16079a42..aefc2187 100644
--- a/ext/fg/css/client.css
+++ b/ext/fg/css/client.css
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-iframe.yomichan-popup {
+iframe#yomichan-popup {
all: initial;
border: 1px solid #999;
box-shadow: 0 0 10px rgba(0, 0, 0, .5);
diff --git a/ext/fg/js/client.js b/ext/fg/js/client.js
index 7e9a9896..303f959b 100644
--- a/ext/fg/js/client.js
+++ b/ext/fg/js/client.js
@@ -87,6 +87,8 @@ class Client {
return;
}
+ range.setLength(this.options.scanLength);
+
if (this.lastRange !== null && this.lastRange.equals(range)) {
return;
}
@@ -113,7 +115,7 @@ class Client {
this.popup.showNextTo(range, content);
if (this.options.highlightText) {
- this.range.select(length);
+ range.select(length);
}
this.lastRange = range;
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index 694aa6b7..4c5a01d8 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -49,8 +49,8 @@ class Popup {
posY = elementRect.top - popupRect.height - this.offset;
}
- this.popup.style.left = pos.x + 'px';
- this.popup.style.top = pos.y + 'px';
+ this.popup.style.left = posX + 'px';
+ this.popup.style.top = posY + 'px';
this.popup.style.visibility = 'visible';
this.setContent(content);
diff --git a/ext/fg/js/range.js b/ext/fg/js/range.js
index cf568a9c..85430a7b 100644
--- a/ext/fg/js/range.js
+++ b/ext/fg/js/range.js
@@ -35,16 +35,16 @@ class Range {
return null;
}
- range.setEnd(node, offset + length);
+ this.range.setEnd(node, offset + length);
return length;
}
containsPoint(point) {
- const rect = this.paddedRect();
+ const rect = this.getBoundingClientRect();
return point.x >= rect.left && point.x <= rect.right;
}
- paddedRect() {
+ getBoundingClientRect() {
const range = this.range.cloneRange();
const startOffset = range.startOffset;
const endOffset = range.endOffset;
@@ -72,8 +72,8 @@ class Range {
equals(range) {
const equal =
- range.compareBoundaryPoints(Range.END_TO_END, this.range) === 0 &&
- range.compareBoundaryPoints(Range.START_TO_START, this.range) === 0;
+ range.range.compareBoundaryPoints(Range.END_TO_END, this.range) === 0 &&
+ range.range.compareBoundaryPoints(Range.START_TO_START, this.range) === 0;
return equal;