fix the popup width bug in FF when scrollbar is shown

* scrollbar width is not subtracted in FF from the actual width
* in some versions of FF the paddings should be added on both sides
This commit is contained in:
tophf 2017-12-13 23:13:35 +03:00
parent 8265d0c8e4
commit 4601a136a9

View File

@ -111,6 +111,17 @@ window.addEventListener('showStyles:done', function _() {
dom.list = $('#search-results-list'); dom.list = $('#search-results-list');
addEventListener('scroll', loadMoreIfNeeded, {passive: true}); addEventListener('scroll', loadMoreIfNeeded, {passive: true});
if (FIREFOX) {
addEventListener('resize', () => {
const scrollbarWidth = window.innerWidth - document.scrollingElement.clientWidth;
if (scrollbarWidth !== parseFloat(document.body.style.paddingRight)) {
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');
}
});
}
addEventListener('styleDeleted', ({detail}) => { addEventListener('styleDeleted', ({detail}) => {
const entries = [...dom.list.children]; const entries = [...dom.list.children];