summaryrefslogtreecommitdiff
path: root/ext/js/app/popup.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-09-30 21:05:34 -0400
committerGitHub <noreply@github.com>2021-09-30 21:05:34 -0400
commit19eb990aeb197f70a0cf46efdf9f2bdd6ed1d48c (patch)
tree5215d2e1d669e4576cd5c345e400727de93999eb /ext/js/app/popup.js
parent6cf01555e7ea8d8f795188d16b2de5df58d0a110 (diff)
DOMRect update (#1973)
* Compare using left/top rather than x/y * Simplify * Update Popup*.getFrameRect to return a custom structure * Don't use x/y on DOMRect
Diffstat (limited to 'ext/js/app/popup.js')
-rw-r--r--ext/js/app/popup.js17
1 files changed, 9 insertions, 8 deletions
diff --git a/ext/js/app/popup.js b/ext/js/app/popup.js
index 8bf1d7c9..347cbb84 100644
--- a/ext/js/app/popup.js
+++ b/ext/js/app/popup.js
@@ -142,7 +142,7 @@ class Popup extends EventDispatcher {
async containsPoint(x, y) {
for (let popup = this; popup !== null && popup.isVisibleSync(); popup = popup.child) {
const rect = popup.getFrameRect();
- if (x >= rect.left && y >= rect.top && x < rect.right && y < rect.bottom) {
+ if (rect.valid && x >= rect.x && y >= rect.y && x < rect.x + rect.width && y < rect.y + rect.height) {
return true;
}
}
@@ -203,12 +203,13 @@ class Popup extends EventDispatcher {
}
getFrameRect() {
- return this._frame.getBoundingClientRect();
+ const {left, top, width, height} = this._frame.getBoundingClientRect();
+ return {x: left, y: top, width, height, valid: true};
}
async getFrameSize() {
- const rect = this._frame.getBoundingClientRect();
- return {width: rect.width, height: rect.height, valid: true};
+ const {width, height} = this._frame.getBoundingClientRect();
+ return {width, height, valid: true};
}
async setFrameSize(width, height) {
@@ -535,16 +536,16 @@ class Popup extends EventDispatcher {
const verticalOffset = optionsGeneral.popupVerticalOffset * offsetScale;
const [x, w] = this._getConstrainedPosition(
- elementRect.right - horizontalOffset,
- elementRect.left + horizontalOffset,
+ elementRect.x + elementRect.width - horizontalOffset,
+ elementRect.x + horizontalOffset,
width,
viewport.left,
viewport.right,
true
);
const [y, h, below] = this._getConstrainedPositionBinary(
- elementRect.top - verticalOffset,
- elementRect.bottom + verticalOffset,
+ elementRect.y - verticalOffset,
+ elementRect.y + elementRect.height + verticalOffset,
height,
viewport.top,
viewport.bottom,