diff options
| author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-01-11 14:16:58 -0500 | 
|---|---|---|
| committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-01-22 20:38:21 -0500 | 
| commit | 21dbb19565d2a0b024d3240d93a961c989504bcb (patch) | |
| tree | d602b28ebe71583a32a8fcba61d93ab1c09cb726 /ext/fg/js | |
| parent | e73e4c032c2fbbeee1e1b4ce89a8627bb60d5dbb (diff) | |
Update popup position on scroll
Diffstat (limited to 'ext/fg/js')
| -rw-r--r-- | ext/fg/js/frontend.js | 23 | 
1 files changed, 16 insertions, 7 deletions
| diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 43cbae73..e1021ce8 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -46,6 +46,7 @@ class Frontend extends TextScanner {              const {zoomFactor} = await apiGetZoom();              this._pageZoomFactor = zoomFactor; +            window.addEventListener('scroll', this.onScroll.bind(this), false);              window.addEventListener('resize', this.onResize.bind(this), false);              const visualViewport = window.visualViewport; @@ -65,11 +66,12 @@ class Frontend extends TextScanner {          }      } -    async onResize() { -        const textSource = this.getCurrentTextSource(); -        if (textSource !== null && await this.popup.isVisible()) { -            this._showPopupContent(textSource); -        } +    onResize() { +        this._updatePopupPosition(); +    } + +    onScroll() { +        this._updatePopupPosition();      }      onWindowMessage(e) { @@ -99,7 +101,7 @@ class Frontend extends TextScanner {      }      onVisualViewportScroll() { -        // TODO +        this._updatePopupPosition();      }      onVisualViewportResize() { @@ -224,7 +226,14 @@ class Frontend extends TextScanner {          this._contentScale = contentScale;          this.popup.setContentScale(this._contentScale); -        this.onResize(); +        this._updatePopupPosition(); +    } + +    async _updatePopupPosition() { +        const textSource = this.getCurrentTextSource(); +        if (textSource !== null && await this.popup.isVisible()) { +            this._showPopupContent(textSource); +        }      }      static _getVisualViewportScale() { |