aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/range.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-04-22 22:25:12 -0700
committerAlex Yatskov <alex@foosoft.net>2016-04-22 22:25:12 -0700
commitb8df875e030eabb73b67a9a9c721c6922145a8c9 (patch)
treea5ff686d3df86bddfc826ccce82617f7f93cc637 /ext/fg/js/range.js
parent85594f4def54d14558415d4594fcf810c26cad75 (diff)
WIP
Diffstat (limited to 'ext/fg/js/range.js')
-rw-r--r--ext/fg/js/range.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/fg/js/range.js b/ext/fg/js/range.js
index 819bbfd8..18c0d6bb 100644
--- a/ext/fg/js/range.js
+++ b/ext/fg/js/range.js
@@ -39,6 +39,11 @@ class Range {
return length;
}
+ containsPoint(point) {
+ const rect = this.paddedRect();
+ return point.x >= rect.left && point.x <= rect.right;
+ }
+
paddedRect() {
const node = this.range.startContainer;
const startOffset = this.range.startOffset;
@@ -53,7 +58,7 @@ class Range {
return rect;
}
- static fromPoint(point) {
+ static fromPos(point) {
const range = document.caretRangeFromPoint(point.x, point.y);
return range === null ? null : new Range(range);
}