summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2020-03-07 04:20:52 +0200
committerGitHub <noreply@github.com>2020-03-07 04:20:52 +0200
commit58d734b8f79a9d859063ef70afe1ff367afe7a29 (patch)
tree2fbdb5592497f195950052258c20ffd43ccb155b
parent421b60db0f6f132cbc5993488041846055a76d11 (diff)
parent9fef0751f3dc7f213f158a50124371f0c6fb5a17 (diff)
Merge pull request #395 from siikamiika/fix-containspoint-offset
adjust containsPoint offset with nested popups
-rw-r--r--ext/fg/js/popup-proxy-host.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js
index bef2cb16..7d86aa67 100644
--- a/ext/fg/js/popup-proxy-host.js
+++ b/ext/fg/js/popup-proxy-host.js
@@ -116,6 +116,7 @@ class PopupProxyHost {
async _onApiContainsPoint({id, x, y}) {
const popup = this._getPopup(id);
+ [x, y] = PopupProxyHost._convertPopupPointToRootPagePoint(popup, x, y);
return await popup.containsPoint(x, y);
}
@@ -152,14 +153,17 @@ class PopupProxyHost {
}
static _convertJsonRectToDOMRect(popup, jsonRect) {
- let x = jsonRect.x;
- let y = jsonRect.y;
+ const [x, y] = PopupProxyHost._convertPopupPointToRootPagePoint(popup, jsonRect.x, jsonRect.y);
+ return new DOMRect(x, y, jsonRect.width, jsonRect.height);
+ }
+
+ static _convertPopupPointToRootPagePoint(popup, x, y) {
if (popup.parent !== null) {
const popupRect = popup.parent.getContainerRect();
x += popupRect.x;
y += popupRect.y;
}
- return new DOMRect(x, y, jsonRect.width, jsonRect.height);
+ return [x, y];
}
static _popupCanShow(popup) {