summaryrefslogtreecommitdiff
path: root/ext/js/app/frontend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2022-05-16 21:45:22 -0400
committerGitHub <noreply@github.com>2022-05-16 21:45:22 -0400
commit63d37c872b786abe9233d70b2eff0362582cbc3a (patch)
treee3fd32f96b3734070876e8623acacc76666a0edf /ext/js/app/frontend.js
parent96f5a06c80b985a503a1e30e2cb6d346cb361aba (diff)
Popup positioning improvements (#2135)
* Rename elementRect to sourceRect * Add getRects function to TextSourceElement and TextSourceRange * Add jsdocs * Remove unnecessary valid parameter * Remove default parameter * Make optionsContext optional * Remove unnecessary checks * Update sourceRect to use left/right rather than x/y * Update the return type of Popup*.getFrameRect * Rename some unrelated rect vars for disambiguation * Disambiguate between Popup.Rect and Popup.ValidRect * Move sourceRect destructuring * Pass multiple source rects * Simplify * Change Rect to use right/bottom rather than width/height * Update how popup offset is applied * Simplify frame offset * Remove _applyFrameOffset * Use right/bottom rather than width/height * Simplify some positioning settings * Update parameter names for clarity * Fix typos * Refactor data type for _getPosition* functions * Support using multiple source rects * Combine _getPosition functions * Refactor * Expose after dataset value * Consistently use this's property * Add jsdoc
Diffstat (limited to 'ext/js/app/frontend.js')
-rw-r--r--ext/js/app/frontend.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/ext/js/app/frontend.js b/ext/js/app/frontend.js
index 102cd299..634408d9 100644
--- a/ext/js/app/frontend.js
+++ b/ext/js/app/frontend.js
@@ -565,7 +565,7 @@ class Frontend {
textSource = this._textScanner.getCurrentTextSource();
if (textSource === null) { return; }
}
- this._showPopupContent(textSource, null);
+ this._showPopupContent(textSource, null, null);
}
_showContent(textSource, focus, dictionaryEntries, type, sentence, documentTitle, optionsContext) {
@@ -601,14 +601,17 @@ class Frontend {
this._showPopupContent(textSource, optionsContext, details);
}
- _showPopupContent(textSource, optionsContext, details=null) {
- const {left, top, width, height} = textSource.getRect();
+ _showPopupContent(textSource, optionsContext, details) {
+ const sourceRects = [];
+ for (const {left, top, right, bottom} of textSource.getRects()) {
+ sourceRects.push({left, top, right, bottom});
+ }
this._lastShowPromise = (
this._popup !== null ?
this._popup.showContent(
{
optionsContext,
- elementRect: {x: left, y: top, width, height, valid: true},
+ sourceRects,
writingMode: textSource.getWritingMode()
},
details
@@ -661,7 +664,7 @@ class Frontend {
this._popup !== null &&
await this._popup.isVisible()
) {
- this._showPopupContent(textSource, null);
+ this._showPopupContent(textSource, null, null);
}
}