aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-17 18:39:12 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-17 18:40:43 -0400
commit8f918c63dcf82bfcdba47100194b34e4be2dd531 (patch)
tree88bc1d06864ad0f0db8756c0f5bd3c03b456fff4 /ext
parent598cd32946c8e10e5aa3fcec26e3fc40af44bddf (diff)
Reposition popup on window resize rather than clear the search
Fixes #107
Diffstat (limited to 'ext')
-rw-r--r--ext/fg/js/frontend.js10
-rw-r--r--ext/fg/js/popup-proxy-host.js8
-rw-r--r--ext/fg/js/popup-proxy.js5
-rw-r--r--ext/fg/js/popup.js4
4 files changed, 24 insertions, 3 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index eddbf9cc..45d24329 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -139,8 +139,14 @@ class Frontend {
}
}
- onResize() {
- this.searchClear(false);
+ async onResize() {
+ if (this.textSourceLast !== null && await this.popup.isVisibleAsync()) {
+ const textSource = this.textSourceLast;
+ this.lastShowPromise = this.popup.showContent(
+ textSource.getRect(),
+ textSource.getWritingMode()
+ );
+ }
}
onClick(e) {
diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js
index dcdce604..d8dec4df 100644
--- a/ext/fg/js/popup-proxy-host.js
+++ b/ext/fg/js/popup-proxy-host.js
@@ -40,6 +40,7 @@ class PopupProxyHost {
createNestedPopup: ({parentId}) => this.createNestedPopup(parentId),
setOptions: ({id, options}) => this.setOptions(id, options),
hide: ({id, changeFocus}) => this.hide(id, changeFocus),
+ isVisibleAsync: ({id}) => this.isVisibleAsync(id),
setVisibleOverride: ({id, visible}) => this.setVisibleOverride(id, visible),
containsPoint: ({id, x, y}) => this.containsPoint(id, x, y),
showContent: ({id, elementRect, writingMode, type, details}) => this.showContent(id, elementRect, writingMode, type, details),
@@ -97,9 +98,14 @@ class PopupProxyHost {
return popup.hide(changeFocus);
}
+ async isVisibleAsync(id) {
+ const popup = this.getPopup(id);
+ return await popup.isVisibleAsync();
+ }
+
async setVisibleOverride(id, visible) {
const popup = this.getPopup(id);
- return popup.setVisibleOverride(visible);
+ return await popup.setVisibleOverride(visible);
}
async containsPoint(id, x, y) {
diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js
index 53b68872..e62a4868 100644
--- a/ext/fg/js/popup-proxy.js
+++ b/ext/fg/js/popup-proxy.js
@@ -58,6 +58,11 @@ class PopupProxy {
return await this.invokeHostApi('hide', {id: this.id, changeFocus});
}
+ async isVisibleAsync() {
+ const id = await this.getPopupId();
+ return await this.invokeHostApi('isVisibleAsync', {id});
+ }
+
async setVisibleOverride(visible) {
const id = await this.getPopupId();
return await this.invokeHostApi('setVisibleOverride', {id, visible});
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index 6c24c0ce..b5eb9fe2 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -239,6 +239,10 @@ class Popup {
}
}
+ async isVisibleAsync() {
+ return this.isVisible();
+ }
+
isVisible() {
return this.isInjected && (this.visibleOverride !== null ? this.visibleOverride : this.visible);
}