From 04727a8cd7dc29a02595690389979ec1070bbded Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 18 Jan 2020 13:13:12 -0500 Subject: [PATCH] Fix viewport issues when popupScaleRelativeToVisualViewport is disabled --- ext/fg/js/popup.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index ef1334bd..e7dae93e 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -502,16 +502,26 @@ class Popup { } static _getViewport(useVisualViewport) { - if (useVisualViewport) { - const visualViewport = window.visualViewport; - if (visualViewport !== null && typeof visualViewport === 'object') { - const left = visualViewport.offsetLeft; - const top = visualViewport.offsetTop; + const visualViewport = window.visualViewport; + if (visualViewport !== null && typeof visualViewport === 'object') { + const left = visualViewport.offsetLeft; + const top = visualViewport.offsetTop; + const width = visualViewport.width; + const height = visualViewport.height; + if (useVisualViewport) { return { left, top, - right: left + visualViewport.width, - bottom: top + visualViewport.height + right: left + width, + bottom: top + height + }; + } else { + const scale = visualViewport.scale; + return { + left: 0, + top: 0, + right: Math.max(left + width, width * scale), + bottom: Math.max(top + height, height * scale) }; } }