1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-06-14 16:25:03 +12:00

less glitchy autoresize of the popup while in use

This commit is contained in:
gorhill 2015-05-16 19:01:52 -04:00
parent cbc0337110
commit 303291fe09

View file

@ -1578,6 +1578,7 @@ vAPI.toolbarButton.onBeforeCreated = function(doc) {
.appendChild(panel)
.appendChild(iframe);
var scrollBarWidth = 0;
var updateTimer = null;
var delayedResize = function() {
if ( updateTimer ) {
@ -1591,18 +1592,22 @@ vAPI.toolbarButton.onBeforeCreated = function(doc) {
panel.parentNode.style.maxWidth = 'none';
// We set a limit for height
var height = Math.min(body.clientHeight, 600);
var width = body.clientWidth;
// https://github.com/chrisaljoudi/uBlock/issues/730
// Voodoo programming: this recipe works
panel.style.setProperty('height', height + 'px');
iframe.style.setProperty('height', height + 'px');
// Adjust width for presence/absence of vertical scroll bar which may
// have appeared as a result of last operation.
var contentWindow = iframe.contentWindow;
var width = body.clientWidth;
if ( contentWindow.scrollMaxY !== 0 ) {
width += scrollBarWidth;
}
panel.style.setProperty('width', width + 'px');
var cw = panel.clientWidth;
var dw = iframe.contentWindow.document.documentElement.clientWidth;
if ( cw !== dw ) {
width = 2 * cw - dw;
// scrollMaxX should always be zero once we know the scrollbar width
if ( contentWindow.scrollMaxX !== 0 ) {
scrollBarWidth = contentWindow.scrollMaxX;
width += scrollBarWidth;
panel.style.setProperty('width', width + 'px');
}
if ( iframe.clientHeight !== height || panel.clientWidth !== width ) {