more reliable centering of the popup in FF

This commit is contained in:
tophf 2017-12-19 07:05:07 +03:00
parent a8f292815a
commit 3178ee9f10

View File

@ -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;
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');
}
});
`0 ${scrollbarWidth + shift}px 0 ${-shift}px`, 'important');
}, {passive: true});
}
addEventListener('styleDeleted', ({detail: {id}}) => {