From 3178ee9f10f201e8924c430b90d80837bc484b7c Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 19 Dec 2017 07:05:07 +0300 Subject: [PATCH] more reliable centering of the popup in FF --- popup/search-results.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/popup/search-results.js b/popup/search-results.js index 502e8a3c..e3a085a3 100755 --- a/popup/search-results.js +++ b/popup/search-results.js @@ -117,17 +117,15 @@ window.addEventListener('showStyles:done', function _() { addEventListener('scroll', loadMoreIfNeeded, {passive: true}); if (FIREFOX) { - let lastScrollbarWidth; + let lastShift; addEventListener('resize', () => { const scrollbarWidth = window.innerWidth - document.scrollingElement.clientWidth; - if (lastScrollbarWidth !== scrollbarWidth) { - lastScrollbarWidth = scrollbarWidth; - dom.marginLeft = dom.marginLeft || parseFloat(getComputedStyle(dom.container).marginLeft); - const shift = dom.container.getBoundingClientRect().left - dom.marginLeft; - document.body.style.setProperty('padding', - `0 ${scrollbarWidth - shift}px 0 ${shift}px`, 'important'); - } - }); + const shift = document.body.getBoundingClientRect().left; + if (!scrollbarWidth || shift === lastShift) return; + lastShift = shift; + document.body.style.setProperty('padding', + `0 ${scrollbarWidth + shift}px 0 ${-shift}px`, 'important'); + }, {passive: true}); } addEventListener('styleDeleted', ({detail: {id}}) => {