From da8cc90ab4ac97a0a58a2c511a6acdd2eb35d7bd Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 27 Apr 2017 07:38:26 -0400 Subject: [PATCH] fix visual glitch in recent versions of Chromium --- src/js/popup.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/js/popup.js b/src/js/popup.js index 013e2c6..f83029d 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -1000,13 +1000,6 @@ var makeMenu = function() { renderMatrixHeaderRow(); - // Manually adjust the position of the main matrix according to the height - // of the toolbar/matrix header. - document.querySelector('.paneContent').style.setProperty( - 'padding-top', - document.querySelector('.paneHead').clientHeight + 'px' - ); - startMatrixUpdate(); makeMatrixGroup0(groupStats[0]); makeMatrixGroup1(groupStats[1]); @@ -1274,9 +1267,26 @@ var onMatrixSnapshotReady = function(response) { /******************************************************************************/ -var resizePopup = function() { - document.body.setAttribute('data-resize-popup', 'true'); -}; +var resizePopup = (function() { + var timer; + var fix = function() { + timer = undefined; + var doc = document; + // Manually adjust the position of the main matrix according to the + // height of the toolbar/matrix header. + doc.querySelector('.paneContent').style.setProperty( + 'padding-top', + (doc.querySelector('.paneHead').clientHeight + 2) + 'px' + ); + doc.body.setAttribute('data-resize-popup', 'true'); + }; + return function() { + if ( timer !== undefined ) { + clearTimeout(timer); + } + timer = vAPI.setTimeout(fix, 97); + }; +})(); /******************************************************************************/ @@ -1430,6 +1440,8 @@ uDom('#matList').on('click', '.g4Meta', function() { resizePopup(); }); +resizePopup(); + /******************************************************************************/ })();