Mostly working

This commit is contained in:
Alex Yatskov 2016-04-23 21:24:45 -07:00
parent c8d0ef5004
commit 659bb87a59
4 changed files with 11 additions and 9 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;